BLACK FRIDAY: Save 50% on all my Swift books and bundles! >>

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!

   

Save 50% in my WWDC sale.

SAVE 50% All our books and bundles are half price for Black Friday, so you can take your Swift knowledge further without spending big! Get the Swift Power Pack to build your iOS career faster, get the Swift Platform Pack to builds apps for macOS, watchOS, and beyond, or get the Swift Plus Pack to learn advanced design patterns, testing skills, and more.

Save 50% on all our books and bundles!

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.