提交 c614886a 编写于 作者: DCloud_iOS_XHY's avatar DCloud_iOS_XHY

iOS平台修改native-view 示例

上级 b1abc1fe
...@@ -2,19 +2,19 @@ import { UIButton, UIControl,ButtonType } from "UIKit" ...@@ -2,19 +2,19 @@ import { UIButton, UIControl,ButtonType } from "UIKit"
export class NativeButton { export class NativeButton {
element : UniObjectElement; element : UniNativeViewElement;
button : UIButton; button : UIButton;
constructor(element : UniObjectElement) { constructor(element : UniNativeViewElement) {
this.element = element; this.element = element;
this.button = new UIButton(type=UIButton.ButtonType.system) this.button = new UIButton(type=UIButton.ButtonType.system)
super.init() super.init()
// 在 swift target-action 对应的方法需要以OC的方式来调用,那么OC语言中用Selector来表示一个方法的名称(又称方法选择器),创建一个Selector可以使用 Selector("functionName") 的方式。 // 在 swift target-action 对应的方法需要以OC的方式来调用,那么OC语言中用Selector来表示一个方法的名称(又称方法选择器),创建一个Selector可以使用 Selector("functionName") 的方式。
const method = Selector("buttonClickAction") const method = Selector("buttonClickAction")
// button 添加点击回调 // button 添加点击回调
button.addTarget(this, action = method, for = UIControl.Event.touchUpInside) button.addTarget(this, action = method, for = UIControl.Event.touchUpInside)
this.bind(); this.bind();
} }
...@@ -34,7 +34,7 @@ export class NativeButton { ...@@ -34,7 +34,7 @@ export class NativeButton {
*/ */
@objc buttonClickAction() { @objc buttonClickAction() {
// 发送事件 // 发送事件
let event = new UniObjectCustomEvent("customClick") let event = new UniNativeViewEvent("customClick")
this.element.dispatchEvent(event) this.element.dispatchEvent(event)
} }
......
...@@ -48,7 +48,8 @@ export class NativeTimePicker { ...@@ -48,7 +48,8 @@ export class NativeTimePicker {
this.m = minute this.m = minute
this.updateTime() this.updateTime()
} }
// 更新显示
updateTime() { updateTime() {
let formatter = DateFormatter() let formatter = DateFormatter()
formatter.dateFormat = "HH:mm" formatter.dateFormat = "HH:mm"
...@@ -74,7 +75,7 @@ export class NativeTimePicker { ...@@ -74,7 +75,7 @@ export class NativeTimePicker {
let minuteString = formatter.string(from = this.timePicker.date) let minuteString = formatter.string(from = this.timePicker.date)
const detail = { "hour": hourString, "minute": minuteString } const detail = { "hour": hourString, "minute": minuteString }
const event = new UniObjectCustomEvent("timechanged", detail) const event = new UniNativeViewEvent("timechanged", detail)
this.element.dispatchEvent(event) this.element.dispatchEvent(event)
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册