Post

Replies

Boosts

Views

Activity

SwiftUI Dynamic Type Change with NavigationView pushes extra view controllers
This feels so simple that we must be doing something wrong. When we change the font-size in the accessibility inspector, in the worst-case, we get a crash. In the best case, it pushes a new view controller on to the stack. This was the simplest example we had: swift struct Fruit: Identifiable, Hashable {   var id: String } struct ContentView: View {   @State var fruit = [Fruit(id: "Apples"), Fruit(id: "Cherries"), Fruit(id: "Grapes")]       var body: some View {     NavigationView {       List {         ForEach(fruit) { item in           NavigationLink(destination: Text("Hello World")) {             Text(item.id)           }         }       }.navigationTitle("Fruit")     }.navigationViewStyle(StackNavigationViewStyle())   } } If we load this up, then select one of the fruit to push on the detail page, when we change the font size in the accessibility inspector, it pushes on the DetailView again so that we have three view controllers in the stack. Originally, we had three levels instead of two and we weren't setting the navigationViewStyle. In this case, it defaulted to a DoubleColumn style and crashed trying to push on the same view controller instance. The apple sample code we tested also had this issue. Tested on Xcode 12.4 on both simulators and devices.
5
0
2.9k
Mar ’21