手表按钮按下崩溃 [英] watch button press crash
问题描述
它似乎与
转到 WatchKit 扩展 > InterfaceController.swift 并添加一个新成员
@IBOutlet var scheduleMeetingButton: WKInterfaceButton!
和方法
@IBAction func scheduleMeeting(_ sender: Any) { }
然后返回Interface.storyboard并将这两个链接到按钮
启动应用程序(在手表模拟器上)
然后点击按钮,你会得到这个执行错误
是什么导致了这个错误?
从查看您的代码来看,我建议将 action 函数从 sender: any 更新为 sender: wkinterfacebutton 希望这会有所帮助!
it seems to be the same error and conditions as this unanswered SO question, but I have more to add (its really easy to replicate)
Create a new project in the latest Xcode
iOS App with WatchKit App
Go to the WatchKit App > Interface.storyboard and put a single button on the Interface Controller Scene > Interface Controller
Go to WatchKit Extension > InterfaceController.swift and add a new member
@IBOutlet var scheduleMeetingButton: WKInterfaceButton!
and method
@IBAction func scheduleMeeting(_ sender: Any) { }
then go back to Interface.storyboard and link both of these to the button
launch the app (on the watch simulator)
than click the button and you will get this exec error
What is causing this error?
From looking at your code i would suggest updating the action function from sender: any to sender: wkinterfacebutton hope this helps!
这篇关于手表按钮按下崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!