mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-26 03:01:51 +08:00
refactor(core-modules): implement createNativeView and initNativeView for all components
refactor(core-modules): implement createNativeView and initNativeView for all components
This commit is contained in:

committed by
Martin Yankov

parent
71107533bb
commit
46705ee332
@ -11,14 +11,22 @@ export class DatePicker extends DatePickerBase {
|
||||
private _changeHandler: NSObject;
|
||||
public nativeViewProtected: UIDatePicker;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.nativeViewProtected = UIDatePicker.new();
|
||||
this.nativeViewProtected.datePickerMode = UIDatePickerMode.Date;
|
||||
public createNativeView() {
|
||||
const picker = UIDatePicker.new();
|
||||
picker.datePickerMode = UIDatePickerMode.Date;
|
||||
return picker;
|
||||
}
|
||||
|
||||
public initNativeView(): void {
|
||||
super.initNativeView();
|
||||
const nativeView = this.nativeViewProtected;
|
||||
this._changeHandler = UIDatePickerChangeHandlerImpl.initWithOwner(new WeakRef(this));
|
||||
this.nativeViewProtected.addTargetActionForControlEvents(this._changeHandler, "valueChanged", UIControlEvents.ValueChanged);
|
||||
nativeView.addTargetActionForControlEvents(this._changeHandler, "valueChanged", UIControlEvents.ValueChanged);
|
||||
}
|
||||
|
||||
public disposeNativeView() {
|
||||
this._changeHandler = null;
|
||||
super.disposeNativeView();
|
||||
}
|
||||
|
||||
get ios(): UIDatePicker {
|
||||
|
Reference in New Issue
Block a user