我已经尝试了以下针对 iOS 10.0/Watch OS 3.0 和 iOS 11.0/Watch OS 4.0 的代码,并在模拟器和我的 Watch OS 4 设备中进行了测试。似乎什么都没有触发 crownDidRotate
委托(delegate)方法。
简单的接口(interface),一个标签连接到 socket 。我知道它已连接,因为我更改了 awake
中的文本方法。当我旋转表冠时,代理方法的中断永远不会停止。
有任何想法吗?
import Foundation
import WatchKit
class InterfaceController: WKInterfaceController, WKCrownDelegate {
var value = 1
@IBOutlet var label: WKInterfaceLabel!
override func awake(withContext context: Any?) {
super.awake(withContext: context)
label.setText("Yeah?")
crownSequencer.delegate = self
crownSequencer.focus()
}
func crownDidRotate(_ crownSequencer: WKCrownSequencer?, rotationalDelta: Double) {
label.setText("Rotational: \(rotationalDelta)")
}
}
最佳答案
我也有同样的经历。作为 hack,我在 willActivate() 中添加了对crownSequencer.focus() 的另一个调用,现在我看到了事件。 (xcode 9.0 gm,ios 11.0 gm,watchos 4.0 gm)
关于xcode - WKCrownDelegate 似乎不适用于 Xcode 9 GM,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46249328/