My SwiftUI View doesnt update navigation title for third level
Share
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
In SwiftUI, if your view is not updating the navigation title for the third level, there are a few things you can try:
.navigationBarTitle()
modifier is being applied to the view in question. It should be applied to the view that is being pushed onto the navigation stack, not the view that is doing the pushing..navigationBarTitle()
modifier. Make sure that you are passing the correct property or state that should be displayed as the title.NavigationLink
to navigate to the next page, you can use thedestination
parameter of theNavigationLink
to set the title of the destination viewCopy code
NavigationLink(destination: DetailView(title: "Detail Page")) {
Text("Go to Detail Page")
}
NavigationView
inside anotherNavigationView
then you have to set the title for the innerNavigationView
as well.Copy code
NavigationView {
NavigationView {
Text("Detail Page")
.navigationBarTitle("Detail Title")
}
.navigationBarTitle("Outer Title")
}
@State
property wrapper or theObservableObject
protocol to keep the state of your view.By following these suggestions, you should be able to update the navigation title for the third level in your SwiftUI app.