【发布时间】:2021-04-14 20:19:10
【问题描述】:
是否可以让 NavigationView 链接与点击手势 (onLongPressGesture) 共存!?
我不能让它为我的生活工作......
ScrollView {
ForEach(self.itemStore.items) { p in
NavigationLink(destination: Details(p: p)) {
CardDetector(p: p, position: self.position)
}
}
}
struct CardDetector: View {
var p: ListData
@State var position: CardPosition
@Namespace var namespace
var body: some View {
Group {
switch position {
case .small:
smallcardView(p: p, namespace: namespace)
.padding()
.frame(maxWidth: .infinity)
.frame(height: 120)
.background(BlurView(style: .regular))
.cornerRadius(10)
.padding(.vertical,6)
.onLongPressGesture {
withAnimation {
position = .big
}
}
.padding(.horizontal)
这会导致滚动问题...他们说解决方案是添加一个onTapGesture(根据答案:Longpress and list scrolling)但随后NavigationLink 将不起作用!?
【问题讨论】: