0

I am building a simple water tracking app, and I want to use the digital crown for increasing/decreasing the value of drunk water.

However .digitalCrownRotation won't update the value. I have tried everything but without any luck.

What am I doing wrong?

This is my code

struct ContentView: View {
    @State private var counter: Double = 0.0
    var body: some View {
        VStack {
            HStack {
                Text("\(counter, specifier: "%.1f") L")
                    .focusable().digitalCrownRotation(self.$counter, from: 0, through: 5, by: 0.1, sensitivity: .medium, isContinuous: true, isHapticFeedbackEnabled: true)
            }
            Spacer()
            Button("Confirm", action: {
                print("ciao confirm")
            })
        }
    }
}
Danielcraig
  • 121
  • 11
  • 1
    This works. I built it in the simulator and used two fingers on my MacBook trackpad to move the crown. – vacawama Sep 10 '22 at 12:01
  • For me it is not working. I use the two fingers to move the crown but the value remains 0.0 – Danielcraig Sep 10 '22 at 13:21
  • Make sure your mouse pointer is over the watch face. I tested with Xcode 13.4.1. Do you have the scrolling gesture enabled on your trackpad? – vacawama Sep 10 '22 at 13:24
  • If I move my mouse pointer over the watch face, the crown won't move. However if I move the pointer over the crown, i can see it scrolling but does nothing. Yes the scrolling gesture is enabled ofc. – Danielcraig Sep 10 '22 at 13:26
  • What version of Xcode are you using? Have you changed any settings from a default new project? Is this for a standalone watch app? – vacawama Sep 10 '22 at 13:36
  • XCode is v13.4.1, haven't changed any settings. The project is started from an iOS app and later added the watch app. Maybe I should try making only the watchOS app? – Danielcraig Sep 10 '22 at 13:56
  • Try a standalone watch app with your code above. Check the version of the watchOS (Crown->Settings->General-About). Mine is 8.5. – vacawama Sep 10 '22 at 14:01

0 Answers0