我正把脸撞到墙上,试图弄清楚为什么我不能让这个.digitalCrownRotation
功能Text
在 WatchOS 的 SwiftUI 中的 UI 组件上工作。
这是我的代码:
import SwiftUI
struct ButtonView: View {
@State private var isFocused = false
@State private var value: Int = 0
var body: some View {
Button(action: {
print("clicked")
}) {
Text("\(value)")
.contentShape(Rectangle())
.focusable { self.isFocused = $0 }
.digitalCrownRotation(self.$value, from: 0, through: 9, by: 1, sensitivity: .medium, isContinuous: true, isHapticFeedbackEnabled: true)
}
.background(self.isFocused ? Color.green : Color.white)
}
}
一切正常,直到我尝试添加.digitalCrownRotation
功能的指针。
每当我尝试构建时,都会遇到以下 2 条构建失败消息:
参数类型“Int.Stride”(又名“Int”)不符合预期类型“BinaryFloatingPoint”参数类型“Int”不符合预期类型“BinaryFloatingPoint”
当按钮聚焦时,我基本上是在尝试使用数字表冠从 0 到 9 逐步遍历数字(整数)。但它不起作用,我不知道该怎么做才能解决它。