简体   繁体   中英

SwiftUI tap gesture blocks item deleting action in List

So I have a view with List , also this view has side menu. I added tapGesture to my VStack to dismiss side menu when it's open, but then I face issue, tapGesture is blocking onDelete method of List . Any ideas how to fix that??

Here is code example:

VStack {
.....
    List {
          ForEach(){
           //list elements here
          }
          .onDelete {
            // delete action here
          }
    }
}
.onTapGesture {
// action here 
}

Also, if while deleting I swipe once till the end, it's working. But if I swipe just a little and try to press Delete button nothing happens.

Replace your .onTapGesture with the simultaneousGesture modifier.

.simultaneousGesture(TapGesture().onEnded {
    // action here 
})

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM