swiftui:嵌套在scrollview中
我已经尝试了所有我能想到的一切,但是当嵌套在卷轴内时,我无法将此按钮始终如一地发射。如果我将ScrollView更改为列表,它可以正常工作,但是我不希望手表上的列表的UI,我更喜欢使用scrollview。我认为这与系统检测到按钮上的滚动和水龙头的水龙头有关,但不确定如何修复或任何解决方法?
struct WatchWorkoutSummaryView: View {
@EnvironmentObject var workoutManager: WorkoutManager
var body: some View {
ScrollView {
EffortLevelRingViewForWatch(workoutState: WatchWorkoutState.After)
Divider()
.padding(.horizontal)
IntensityViewForWatch()
Divider()
.padding(.horizontal)
HeartRateZonesViewForWatch(workoutState: WatchWorkoutState.After)
Divider()
.padding(.horizontal)
AerobicAnaerobicWatchMasterView()
Divider()
.padding(.horizontal)
VStack {
SummaryView().environmentObject(workoutManager)
Button(action: {
print("button is tapped")
workoutManager.dismissLiveWorkoutTabViewSheet()
workoutManager.resetWorkoutManager()
}, label: {
Text("Done")
.foregroundColor(.white)
})
.background(
Color.buttonColor
.cornerRadius(10)
)
.buttonStyle(BorderedButtonStyle(tint: .clear))
.padding(.horizontal)
.animation(nil)
}
.padding(.vertical)
}
//This doesn't work.
.animation(nil)
}
}
I've tried everything I can think of but I can't get this button to fire consistently when nested inside a ScrollView. If I change the ScrollView to a List, it works fine, but I don't want the UI of a list on the Watch, I would prefer to use a ScrollView. I think it's related to the system detecting taps to scroll and taps on the button but not sure how to fix or any workarounds?
struct WatchWorkoutSummaryView: View {
@EnvironmentObject var workoutManager: WorkoutManager
var body: some View {
ScrollView {
EffortLevelRingViewForWatch(workoutState: WatchWorkoutState.After)
Divider()
.padding(.horizontal)
IntensityViewForWatch()
Divider()
.padding(.horizontal)
HeartRateZonesViewForWatch(workoutState: WatchWorkoutState.After)
Divider()
.padding(.horizontal)
AerobicAnaerobicWatchMasterView()
Divider()
.padding(.horizontal)
VStack {
SummaryView().environmentObject(workoutManager)
Button(action: {
print("button is tapped")
workoutManager.dismissLiveWorkoutTabViewSheet()
workoutManager.resetWorkoutManager()
}, label: {
Text("Done")
.foregroundColor(.white)
})
.background(
Color.buttonColor
.cornerRadius(10)
)
.buttonStyle(BorderedButtonStyle(tint: .clear))
.padding(.horizontal)
.animation(nil)
}
.padding(.vertical)
}
//This doesn't work.
.animation(nil)
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论