Search code examples
watchkitapple-watchwatchos-2

Monitor value of Digital Crown? (Watch OS 2)


I'm trying to figure out if it is possible to read the value of the Digital Crown on my Apple Watch.

I've read that WKInterfacePicker makes that possible, but I'm not really looking for picking an item from a list, I want to do read the value of the Digital Crown and use that value for something inside the app.

For example to move a visual object sideways.

Is this possible? If yes then how can I utilize the Digital Crown?


Solution

  • I found an Apple Dev Forum thread: https://forums.developer.apple.com/message/7580#7580

    The user Svarrall explained how to do it as of current Watch OS 2.

    svarrall Jun 11, 2015 1:16 AM (in response to limtc) It should be possible indirectly. Use an InterfacePicker and add a dummy array to it with the same number of steps as the Slider, but don't show the picker in the interface (It's minimum dimensions seem to be 2x2, not sure if it's still accessible if it's Hidden, haven't tried) then in the Picker's @IBAction func pickerAction(value: Int) use that to update the value of the Slider to match. If you set the Picker's focus style to None and Indicator to Disabled then no-one needs to know it's there. In code setting picker.focusForCrownInput() will make it priority for input. The only issue I've seen with this, is if the Interface is longer than the screen the crown reverts to scrolling the page itself and not the picker. Oh and it's a bit slow to get the picker updates (on device, not simulator)