【发布时间】:2020-11-28 16:54:06
【问题描述】:
我正在尝试在我的应用中实现 WKLongPressGestureRecognizer。长按手势被识别并呈现警报。但是,当我选择清除表格的选项(我正在使用 Realm)时,警报控制器被解除,但未清除拍摄。当我尝试通过在代码中添加断点进行调试时,似乎完全跳过了闭包内的代码。知道我错过了什么吗? (我应该使用警报表的操作表吗?)我尝试了很多不同的东西。这是我一直用来调试的带有打印语句的代码。当前没有触发闭包内的打印语句。
@IBAction func handleLongPress(_ sender: Any) {
print("long press pressed")
WKInterfaceDevice.current().play(.click)
let clearAction = WKAlertAction(title: "Clear", style: .destructive) {
print("clear button pressed")
}
let cancelAction = WKAlertAction(title: "Cancel", style: .default) {
print("cancel button pressed")
}
presentAlert(withTitle: "Are you sure?", message: "Action cannot be undone", preferredStyle: .alert, actions: [clearAction, cancelAction])
print("exiting long press")}
感谢您的任何意见或建议。
【问题讨论】:
标签: xcode watchkit apple-watch