[英].onTapGesture doesn't work on Stepper, only on its text
The .onTapGesture
below only gets called when I tap on the text "Min. amount: $0.01", but when I tap the + or - it doesn't.下面的.onTapGesture
只有在我点击文本“Min. amount: $0.01”时才会被调用,但当我点击 + 或 - 时不会。 How can I get it to work on the + or - as well?我怎样才能让它在 + 或 - 上工作?
I tried setting a frame below the Stepper with:我尝试在步进器下方设置一个框架:
.frame(maxWidth: .infinity, maxHeight: .infinity)
or setting the foreground color but made no difference.或设置前景色但没有区别。 Any idea?任何想法?
Its code:它的代码:
@ViewBuilder var minCoinAmount: some View {
// Min coin amount
Stepper(value: $smallBalanceLimitDefinedByUser,
in: range,
step: step) {
// Separated in two texts so it can be localized properly
HStack {
Text("Min. amount:")
Text(utils.formatDoubleTo2DigitsString(amount: smallBalanceLimitDefinedByUser))
}
}
}
and I'm calling it with:我打电话给它:
minCoinAmount
.disabled(true)
.onTapGesture {
// Presents the Premium page
storeViewModel.premiumIsPresented.toggle()
}
Add hit test area with contentShape modifier, like使用 contentShape 修饰符添加命中测试区域,例如
.contentShape(Rectangle()) // << here !!
.onTapGesture {
Tested with Xcode 13.4 / iOS 15.5使用 Xcode 13.4 / iOS 15.5 测试
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.