Post

Replies

Boosts

Views

Activity

NavigationLink on iPad demands a physical rotation before view appears
The opening view of App only appears after complete rotation of physical device. This is a weird bug. After that rotation everything is peachy-keen-o. I am aware that adding: .navigationViewStyle(StackNavigationViewStyle()) to the NavigationView will sorta resolve the problem. But this solution is a poor fix for my App's needs. Is there a command to intentionally rotate device in code to resolve this? Or some other fix to get that first view to appear without counting on the user to rotate the device? I've tried various solutions with no luck. Below is a quick setup of the problem. struct FirstView: View {     @Binding var viewNum: Int?     var body: some View {         VStack {             Text("View One")                 .padding(20)             Button {                 viewNum = 2             } label: {                 Text("Go to 2nd view")             }         }         .onAppear {             viewNum = 1         }     } } struct MainView: View {     @State var selection: Int? = 1     var body: some View {         VStack {             NavigationView {                 List {                     NavigationLink("First View", tag: 1, selection: $selection){  FirstView1(viewNum: $selection)}                                         NavigationLink("Second View", tag: 2, selection: $selection){                         Text("View 2").padding(20)                         Button {                             selection = 1                         } label: {                             Text("Go to first view")                         }                     }                 }             }            // .navigationViewStyle(StackNavigationViewStyle())         }     } }
1
0
412
Nov ’21