I've tried the code below targeting both iOS 10.0/Watch OS 3.0 and iOS 11.0/Watch OS 4.0, and tested both in the simulator and my Watch OS 4 device. Nothing seems to trigger the crownDidRotate
delegate method.
Simple interface with one label connected to the outlet. I know it's connected because I change the text in the awake
method. Breaking in the delegate method never stops when I rotate the crown.
Any ideas?
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)")
}
}
I had the same experience. As a hack, I added another call to crownSequencer.focus() in willActivate(), and I'm now seeing events. (xcode 9.0 gm, ios 11.0 gm, watchos 4.0 gm)
Adding crownSequencer.focus() in willActivate() did not help me in Xcode10. You don't have to call crownSequencer.focus() neither in awake() or in willActivate() but in didAppear(). So you need to add the following lines:
override func didAppear() {
super.didAppear()
crownSequencer.focus()
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With