Episode #253

Digital Crown

Series: Up to Speed with watchOS

11 minutes
Published on January 27, 2017

This video is only available to subscribers. Get access to this video and 584 others.

In this episode, Conrad Stoll takes us through the new APIs we have for accessing raw information from the digital crown on the Apple Watch. In previous versions of watchOS, we had to resort to using builtin controls (or silly hacks), but now we have the raw data so we have much more flexibility.

Episode Links

Setting up the Crown Sequencer

self.crownSequencer.delegate = self
self.crownSequencer.focus()

Using the Crown Sequencer's Rotational Delta

func crownDidRotate(_ crownSequencer: WKCrownSequencer?, rotationalDelta: Double) {
    if rotationalDelta < 0 {
        // Decreasing
    } else if rotationalDelta > 0 {
        // Increasing
    }
}

Using the Crown Sequencer's Velocity

if let rotationsPerSecond = crownSequencer?.rotationsPerSecond {
    if rotationsPerSecond > 1.0 {
        // Increase delta
    }
}

Noticing When the Crown Stopped Moving

func crownDidBecomeIdle(_ crownSequencer: WKCrownSequencer?) {

}

This episode uses Watchos 3.