How to get title from WKInterfaceButton

2019-02-16 10:56发布

问题:

To get title there is function:

setTitle

But how to get title of WKInterfaceButton as string ?

I did not found anything in https://developer.apple.com/library/prerelease/ios/documentation/WatchKit/Reference/WKInterfaceButton_class/index.html

回答1:

You can't get the state of any WKInterface UI element like buttons (WKInterfaceButton) label (WKInterfaceLabel) etc. I think this is designed by Apple like this because it involve under the hood communication between the extension running on your iOS device & the watch App. To save this overhead there are no getters and the extension should keep track of the state change (it is the one that can change the state).