Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class InterfaceController: WKInterfaceController {
- //... existing code...
- private var crownDelta = 0.0
- private var count: Int = 0 {
- didSet {
- setCount(count: String(count))
- }
- }
- override func awake(withContext context: Any?) {
- super.awake(withContext: context)
- // Configure interface objects here.
- crownSequencer.delegate = self
- }
- override func willActivate() {
- // This method is called when watch view controller is about to be visible to user
- super.willActivate()
- crownSequencer.focus()
- }
- }
- extension InterfaceController: WKCrownDelegate {
- func crownDidRotate(_ crownSequencer: WKCrownSequencer?, rotationalDelta: Double) {
- crownDelta += rotationalDelta
- if crownDelta > 0.1 {
- count += 1
- crownDelta = 0.0
- } else if crownDelta < -0.1 {
- count -= 1
- crownDelta = 0.0
- }
- }
- }
Add Comment
Please, Sign In to add comment