mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 11:42:04 +08:00
Handled text change notifications for iOS label.
This commit is contained in:
@ -22,6 +22,10 @@ export class Observable {
|
|||||||
// true to track the Changing phase, false otherwise
|
// true to track the Changing phase, false otherwise
|
||||||
private _trackChanging = false;
|
private _trackChanging = false;
|
||||||
|
|
||||||
|
constructor(body?: any) {
|
||||||
|
// TODO: Not implemented
|
||||||
|
}
|
||||||
|
|
||||||
public addObserver(eventName: string, callback: (data: ChangeData) => void) {
|
public addObserver(eventName: string, callback: (data: ChangeData) => void) {
|
||||||
this.verifyCallback(callback);
|
this.verifyCallback(callback);
|
||||||
var list = this.getEventList(eventName, true);
|
var list = this.getEventList(eventName, true);
|
||||||
|
@ -12,16 +12,16 @@ export class Label extends view.View {
|
|||||||
|
|
||||||
this._ios = new UIKit.UILabel();
|
this._ios = new UIKit.UILabel();
|
||||||
|
|
||||||
//var extendsBody = Foundation.NSObject.extends(
|
var that = this;
|
||||||
// {
|
var extendsBody = Foundation.NSObject.extends(
|
||||||
// onTextChanged: function (path, sender, change, context) {
|
{
|
||||||
// }
|
observeValueForKeyPathOfObjectChangeContext: function (path: string, sender: Foundation.NSObject, change: Foundation.NSDictionary, context) {
|
||||||
// },
|
that.updateTwoWayBinding(Label.textProperty, change.objectForKey("new"));
|
||||||
// {
|
}
|
||||||
// exposedMethods: { "tick:": "v@:@" }
|
}, {});
|
||||||
// });
|
|
||||||
|
|
||||||
//this.changedHandler = new extendsBody();
|
this.changedHandler = new extendsBody();
|
||||||
|
this._ios.addObserverForKeyPathOptionsContext(this.changedHandler, "text", Foundation.NSKeyValueObservingOptions.NSKeyValueObservingOptionNew, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
get ios(): UIKit.UILabel {
|
get ios(): UIKit.UILabel {
|
||||||
@ -39,12 +39,8 @@ export class Label extends view.View {
|
|||||||
// TODO: Will this be a gigantic if-else switch?
|
// TODO: Will this be a gigantic if-else switch?
|
||||||
if (data.propertyName === Label.textProperty) {
|
if (data.propertyName === Label.textProperty) {
|
||||||
this._ios.text = data.value;
|
this._ios.text = data.value;
|
||||||
|
this._ios.sizeToFit();
|
||||||
} else if (true) {
|
} else if (true) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public addToParent(parent: UIKit.UIView) {
|
|
||||||
super.addToParent(parent);
|
|
||||||
this._ios.sizeToFit();
|
|
||||||
}
|
|
||||||
}
|
}
|
Reference in New Issue
Block a user