5

I am using down simple code for tabView. when I change the orientation of simulator, the app tab jump one tab back. like this if you are in page 2 goes to 1, but it must stays at page 2 how ever I changed the orientation. or if you are in page 3 jump to page 2. why this unwanted jump happens?

struct ContentView: View {
    
    @State var currentPage: Int = 1


    var body: some View {
        
        
        ZStack
        {

            Color.gray.ignoresSafeArea()
            
            
            TabView(selection: $currentPage)
            {
                Text("Hi 1").tag(0)
                Text("Hi 2").tag(1)
                Text("Hi 3").tag(2)
                
            }
            .indexViewStyle(PageIndexViewStyle(backgroundDisplayMode: .never))
            .tabViewStyle(PageTabViewStyle())
            
        }
  
        
    }
}
ios coder
  • 1
  • 4
  • 31
  • 91

0 Answers0