NavigationView inside TabView going to next page by default

Viewed 162

I am wrapping my navigaton view inside a tab view. but when I load the app, my navigation view is always going to its next page by default. How can I stop this ? I spent so much time but could not figure it out.

here is my view

ZStack {
    Color.red
        .edgesIgnoringSafeArea(.all)
    VStack {
                TabView(selection:$selectedTab) {
                    NavigationView {
                        VStack {
                            Text("Hello")
                        }
                            .edgesIgnoringSafeArea(.all)
                    }
                    .tag(1)
                    VStack {
                        Text("Two")
                    }
                    .tag(2)

        }
        .tabViewStyle(PageTabViewStyle(indexDisplayMode: .never))
    }
}

FirstView is a navigation view like this

NavigationView {
    VStack {
        ...
    }
    .sheet(isPresented: $myForm, onDismiss:{  }) {
        NewFormView(...)
    }
    .navigationBarHidden(true)
}

It appears like this enter image description here

0 Answers
Related