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

iOS平台修改native-view 示例

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