UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

SOLVED: NavigationLink requires long press - need tap response

Forums > SwiftUI

I am using a NavigationLink to display a new View in my app. My code functions, but it won't work unless the app user presses and holds on the Text (like a long press gesture). A simple tap gesture (quick press) won't trigger the NavigationLink to display. Please explain how to make the code below open ViewA() on tap/quick press. My iOS deployment target is iOS 15.5. Thank you for your help!

NavigationLink(destination: ViewA()) {
Text("Open View A")
}

   

You will have to show more code so people can understand the context that your NavigationLink is in. I have created a test view with a NavigationLink in it and cannot reproduce your problem.

struct ContentView: View {
    var body: some View {
        NavigationStack {
            NavigationLink(destination: ViewA()) {
                Text("Open View A")
            }
        }
    }
}

It might be worth you creating a separate app to test portions of your code.

Steve

1      

ddcd

   

@barnettsab Thank you, I appreciate your response. I created a separate app, as you suggested. I had the NavigationLink in a Form, which I think was the issue. It's working now as I expected. Thanks again!

   

Hacking with Swift is sponsored by Essential Developer

SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until April 28th.

Click to save your free spot now

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.