watch button press crash

2019-08-19 00:49发布

问题:

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?

回答1:

From looking at your code i would suggest updating the action function from sender: any to sender: wkinterfacebutton hope this helps!