Search code examples
xcodeswiftuiswiftui-navigationlink

NavigationLink are not working but seems ok


I don't see any failures on my navigation link to another view on my SwiftUI app that I am developing on Xcode.

The colour of the text changes to gray but it does not work. In case I am in other view and I come to that view it works and I don't understand why.

NavigationLink(destination: UsernameView().navigationBarBackButtonHidden(true)) {
    Text(" crea una cuenta")
    .font(.normalTitle)
}

And on this other one it works but I receive a warning from the program with an error that I should change. Can you help me to adapt to iOS 16?

.background(
    NavigationLink(destination: ConfirmationView().navigationBarBackButtonHidden(true), 
        isActive: $shouldNavigateToConfirmation) {
            EmptyView()
        }
)

The error on this second code is:

'init(destination:isActive:label:)' was deprecated in iOS 16.0: use NavigationLink(value:label:) inside a NavigationStack or NavigationSplitView

Many thanks!


Solution

  • NavigationLink(destination:) has issues best upgrade to NavigationLink(value:) and navigationDestination.