首页 > 解决方案 > SwiftUI - DragGesture 和 .onDelete 冲突

问题描述

我有手势之间的冲突:

import SwiftUI

struct ContentView : View {

@State var showSearchBar = true

var body : some View {
            NavigationView {
                 Form {
                      ForEach(//code) { values in
                      NavigationLink(//code)
                      }
                      .onDelete(perform: //delete action)
                      }
                    .simultaneousGesture(
                        DragGesture()
                            .onChanged({ gesture in
                                if gesture.location.y > gesture.startLocation.y {
                                    showSearchBar = false
                                } else {
                                    showSearchBar = true
                                }
                            })
                    )}}}

但是,这两种手势都不起作用。如果我删除 .simultaneousGesture,则 .onDelete 有效,但如果我同时保留两者,则只有 .simultaneousGesture 有效。我怎样才能使两者都起作用?

感谢所有帮助我的人!

标签: swiftgesturedraggesture-recognition

解决方案


建议您通过 Apple 开发人员支持提出此问题。


推荐阅读