xcodewatchos

WKCrownDelegate doesn't seem to be working with Xcode 9 GM


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)")
    }
}

Solution

  • 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)