如何从 WKInterfaceButton 获取标题 [英] How to get title from WKInterfaceButton
问题描述
要获得标题有函数:
setTitle
但是如何将 WKInterfaceButton 的标题作为字符串获取?
But how to get title of WKInterfaceButton as string ?
推荐答案
你无法获取任何 WKInterface UI 元素的状态,比如按钮 (WKInterfaceButton) 标签 (WKInterfaceLabel) 等.我认为这是 Apple 设计的这样,因为它涉及在您的 iOS 设备上运行的扩展程序之间的底层通信手表应用程序.为了节省这种开销,没有 getter,并且扩展应该跟踪状态变化(它是可以改变状态的那个).
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).
这篇关于如何从 WKInterfaceButton 获取标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!