Jas*_*n Z 14 button ios swift ios8
如何使用Swift模拟View中的按钮按下.我正在尝试获取日历权限并设置功能以在我单击当前运行的开始按钮时检查此授权
@IBAction func start(sender: AnyObject) {
//loads prompt to "Allow" or "Don't Allow" calendar permissions
eventStore.requestAccessToEntityType(EKEntityTypeEvent, completion: handler)
//checkAuth function looks at calendar authorization to get current status
and then acts accordingly to dismiss View or load Privacy Settings
checkAuth()
}
Run Code Online (Sandbox Code Playgroud)
我需要能够模拟按下"开始"按钮的按钮再次触发start()func.到目前为止,我发现的唯一一件事似乎是在Objective-C中
[buttonObj sendActionsForControlEvents: UIControlEventTouchUpInside];
我不熟悉Obj-C,如果可能的话,需要一种在Swift中实现它的方法......谢谢
Lyn*_*ott 27
Swift翻译:
[buttonObj sendActionsForControlEvents: UIControlEventTouchUpInside];
Run Code Online (Sandbox Code Playgroud)
是:
button.sendActions(for: .touchUpInside)
Run Code Online (Sandbox Code Playgroud)
它实际上应该模拟按钮按下.
kar*_*nms 11
斯威夫特3
button.sendActions(for: UIControlEvents.touchUpInside)
斯威夫特4
button.sendActions(for: .touchUpInside)
| 归档时间: |
|
| 查看次数: |
11252 次 |
| 最近记录: |