Merge pull request #371 from NativeScript/issue-343

Resolved issue #343.
This commit is contained in:
Rossen Hristov
2015-06-30 13:59:40 +03:00
4 changed files with 4 additions and 6 deletions

View File

@ -1,7 +1,7 @@
import placeholder = require("ui/placeholder"); import placeholder = require("ui/placeholder");
export function creatingView(args: placeholder.CreateViewEventData) { export function creatingView(args: placeholder.CreateViewEventData) {
var nativeView = new android.widget.LabelView(args.context); var nativeView = new android.widget.TextView(args.context);
nativeView.setText("Native"); nativeView.setText("Native");
args.view = nativeView; args.view = nativeView;
} }

View File

@ -1,5 +1,5 @@
<Page xmlns="http://www.nativescript.org/tns.xsd"> <Page xmlns="http://www.nativescript.org/tns.xsd">
<StackLayout> <StackLayout>
<Placeholder creatingView="creatingView"/> <Placeholder creatingView="creatingView" width="200" height="200" backgroundColor="red"/>
</StackLayout> </StackLayout>
</Page> </Page>

View File

@ -11,7 +11,7 @@ export class Placeholder extends common.Placeholder {
public _createUI() { public _createUI() {
var args = <definition.CreateViewEventData>{ eventName: common.Placeholder.creatingViewEvent, object: this, view: undefined, context: this._context }; var args = <definition.CreateViewEventData>{ eventName: common.Placeholder.creatingViewEvent, object: this, view: undefined, context: this._context };
this.notify(args); this.notify(args);
this._android = <android.view.View>args.view; this._android = <android.view.View>args.view || new android.view.View(this._context);
} }
get android(): android.view.View { get android(): android.view.View {

View File

@ -10,10 +10,9 @@ export class Placeholder extends common.Placeholder {
get ios(): UIView { get ios(): UIView {
if (!this._ios) { if (!this._ios) {
console.trace();
var args = <definition.CreateViewEventData>{ eventName: common.Placeholder.creatingViewEvent, object: this, view: undefined, context: undefined }; var args = <definition.CreateViewEventData>{ eventName: common.Placeholder.creatingViewEvent, object: this, view: undefined, context: undefined };
super.notify(args); super.notify(args);
this._ios = args.view; this._ios = args.view || new UIView();
} }
return this._ios; return this._ios;
} }
@ -21,5 +20,4 @@ export class Placeholder extends common.Placeholder {
get _nativeView(): UIView { get _nativeView(): UIView {
return this.ios; return this.ios;
} }
} }