Post

Replies

Boosts

Views

Activity

Reply to digitalCrownRotation
This is my code // InterfaceController.swift // Watch App WatchKit Extension // // Created by Maxwell Myers on 1/29/21. // import WatchKit import Foundation class InterfaceController: WKInterfaceController {       @IBOutlet weak var time: WKInterfaceTimer!   @IBOutlet weak var sbutton: WKInterfaceButton!       var timeIsStarted = false   var startTime = Date()   var elapsedTime : TimeInterval = 0.0   private var crownValue = 0.0       override func awake(withContext context: Any?) {     // Configure interface objects here.     super.awake(withContext: context)   }       override func willActivate() {     // This method is called when watch view controller is about to be visible to user     super.willActivate()   }           override func didDeactivate() {     // This method is called when watch view controller is no longer visible     super.didDeactivate()   } //  struct DigitalCrown: View { //    @State private var crownValue = 0.0 // //    var body: some View { //      Text("Received Value:\(crownValue, specifier: "%.1f")") //        .focusable() //        .digitalCrownRotation($crownValue) //    } //  }   @IBAction func stButton() {     timeIsStarted = !timeIsStarted     if timeIsStarted {       startTime = Date()       sbutton.setTitle("STOP")       time .setDate(Date(timeIntervalSinceNow: elapsedTime))       time.start()     }else{       let stoppedTime = Date()       elapsedTime -= stoppedTime.timeIntervalSince(startTime)       sbutton.setTitle("START")       time.stop()     }              }   //    if(crownValue != 0.0) {   //      timeIsStarted = !timeIsStarted //change timeisstarted to true   //      crownValue = 0.0   //    }     }
Topic: App & System Services SubTopic: Core OS Tags:
Mar ’21