Advertisement
srk72

SwiftUI Button or gesture not working solution

Dec 2nd, 2024
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 0.74 KB | Source Code | 0 0
  1. SwiftUI button issue :
  2.  
  3. - If button, navigation, or tap gesture don't work in SwiftUI try this call that code inside this simultaneousGesture :
  4.      NavigationLink(destination: cardItem.destination) {
  5.                         DamageTypeView(cardItem: cardItem)
  6.                     }
  7.                     .border(Color.red)
  8.                     .buttonStyle(PlainButtonStyle()) // Prevent unwanted button styling.
  9.                     .contentShape(Rectangle()) // Make the tappable area clear.
  10.                     .simultaneousGesture(TapGesture().onEnded {
  11.                         print("Tapped 1")
  12.                         // Optional: Add logging or additional handling
  13.                     })
  14.                     .buttonStyle(PlainButtonStyle())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement