Navigation Bar back button delete

So I'm making this app and realised I have two back buttons. From the very first view, when I enter the second view and enter the third view from the second view, I have two back buttons, the very first page back button and the second back button.

How do I get rid of the very first back button?

This is the code for the second view. If the first view's code is quite long so if needed, please ask me

Thank you

import SwiftUI

struct MovieView: View {
    
    @Environment(\.presentationMode) private var presentationMode: Binding<PresentationMode>
    
    var body: some View {
        
        
        NavigationView{
            
            VStack{
                
                List{
                    
                    //Your Name Block
                    NavigationLink {
                        
                        YourNameView()
                        
                    } label: {
                        
                        VStack{
                            
                            Image("your name")
                                .resizable()
                                .aspectRatio(contentMode: .fill)
                                .cornerRadius(20)
                            
                            
                            
                            Text("Your Name")
                                .fontWeight(.bold)
                                .font(.system(size:20))
                            
                        }
                        .padding()
                        .background(Image("beige"))
                        
                        
                    }
                    //notting hill block
                    NavigationLink {
                        NottingHillView()
                    } label: {
                        VStack{
                            Image("notting hill")
                                .resizable()
                                .aspectRatio(contentMode: .fill)
                                .cornerRadius(20)
                            
                            
                            
                            Text("Notting Hill")
                                .fontWeight(.bold)
                                .font(.system(size:20))
                        }               .background(Image("beige"))
                            .padding()
                        
                        
                    }
                    
                    //notting hill block
                    NavigationLink {
                        //Love_OtherDrugsView()
                    } label: {
                        VStack{
                            Image("love and other drugs")
                                .resizable()
                                .aspectRatio(contentMode: .fill)
                                .cornerRadius(20)
                            
                            
                            
                            Text("Love & Other Drugs")
                                .fontWeight(.bold)
                                .font(.system(size:20))
                        }
                        .padding()
                        .background(Image("beige"))
                        
                        
                    }
                    
                    
                }
                .navigationTitle("Movies")
                
                Spacer()
                
                
                    
                    Button {
                        
                    } label: {
                        
                        VStack{
                            
                            Image(systemName: "plus.circle.fill")
                                .resizable()
                                .scaledToFit()
                                .frame(width:24, height:24)
                                .foregroundColor(Color.red)
                            Text("Add movie")
                                .foregroundColor(Color.red)
                            
                        }
                        
                    }

    
                    
             
                    
                    
                }
                
                
            
            
            
        }
        
    }
    
    
    struct MovieView_Previews: PreviewProvider {
        static var previews: some View {
            MovieView()
        }
    }
    
    

}
Answered by Vision Pro Engineer in 761733022

@yh29 , the problem is that you are using nested NavigationViews. If you remove the NavigationView in your MovieView struct, the second back button will go away. Once you have one NavigationView, any view that you have navigated to within this will also be encapsulated in the NavigationView.

Hi @yh29 ,

Could you post a picture of the two back buttons so I can see what you're referencing? Also, are you supporting versions earlier than iOS 16 (eg: iOS 15)?

Thanks!

Hello!

Yes I'm planning to do so.

And here is the code to the first view.

import SwiftUI

struct MainScreenView: View {
        
    var body: some View {
        
        NavigationView{
            
            
            //VStack for Dinner and movie buttons
            VStack{
                
                //Navigation link for going to dinner page
                
                NavigationLink {
                    DinnerView()
                } label: {
                    
                    ZStack{
                        
                        Image("dinner")
                            .resizable()
                            .cornerRadius(20)
                            .shadow(radius:15)
                            .offset(y:12)
                        
                        Text("Dinner")
                            .font(.system(size:70))
                            .fontWeight(.bold)
                            .foregroundColor(Color.white)
                        
                    }
                }
                .padding()
                
                //Navigation link for going to movie page
                NavigationLink{
                    MovieView()
                } label: {
                    
                    ZStack{
                        
                        Image("movie")
                            .resizable()
                            .resizable()
                            .cornerRadius(20)
                            .shadow(radius:15)
                            .offset(y:-5)
                        
                        Text("Movie")
                            .font(.system(size:70))
                            .fontWeight(.bold)
                            .foregroundColor(Color.white)
                        
                    }
                }
                .padding()
                
                
                
            }
            .background(Image("beige"))
            .navigationTitle("Tonight's plan?")
            .navigationBarItems(leading: NavigationLink {
                NotificationView()
            } label: {
                Image(systemName: "bell.fill")
                    .font(.system(size:25))
                    .fontWeight(.bold)
                    .foregroundColor(Color.red)
                    .shadow(radius: 20)
                
            })
            .navigationBarItems(trailing: NavigationLink {
                SettingView()
            } label: {
                Image(systemName: "person.crop.circle")
                    .font(.system(size:25))
                    .fontWeight(.bold)
                    .foregroundColor(Color.red)
                
                
            })
            
            
            
            
            
        }
        
        
    }
    
    
    
    
    struct MainScreenView_Previews: PreviewProvider {
        static var previews: some View {
            MainScreenView()
        }
    }
    
}
Accepted Answer

@yh29 , the problem is that you are using nested NavigationViews. If you remove the NavigationView in your MovieView struct, the second back button will go away. Once you have one NavigationView, any view that you have navigated to within this will also be encapsulated in the NavigationView.

Navigation Bar back button delete
 
 
Q