Home > Back-end >  The "Back" button messes up the view
The "Back" button messes up the view

Time:05-08

I have this problem while working with SwiftUI. So basically, when I press on the navigation link, it opens the screen like this:Picture 1

and because of this, the whole thing below that is pushed lower. And then, when I press to the navigation link from this screen, the result is this:

Picture 2

so it goes even lower and creates the second "back" button.

How do I get rid of this "padding" created by the "back" button?

The way I did the navigations:

    var body: some View {
        NavigationView {
            ZStack {
                Text("Hi")
            }
        }
    }
}

CodePudding user response:

Your issue is that you have duplicate NavigationViews. There are two ways to solve this:

  1. When you call the next view in your NavigationLink, set .navigationBarBackButtonHidden(true). This will disappear the extra back button.

  2. A simpler way; just delete the NavigationView in your second view (the linked one). That will prevent duplicate back buttons.

  • Related