Why does my SwiftUI app crash when navigating backwards after placing a `NavigationLink` inside of a `navigationBarItems` in a `NavigationView`?

后端 未结 9 1150
轮回少年
轮回少年 2020-12-04 12:25

EDIT: This has been fixed in iOS 13.3!

Minimal reproducible example (Xcode 11.2 beta, this works in Xcode 11.1):

struct Parent: View {         


        
9条回答
  •  青春惊慌失措
    2020-12-04 12:37

    This is a major bug and I can't see a proper way to work around it. Worked fine in iOS 13/13.1 but 13.2 crashes.

    You can actually replicate it in a much simpler way (this code is literally all you need).

    struct ContentView: View {
        var body: some View {
            NavigationView {
                Text("Hello, World!").navigationBarTitle("To Do App")
                    .navigationBarItems(leading: NavigationLink(destination: Text("Hi")) {
                        Text("Nav")
                        }
                )
            }
        }
    }
    

    Hope Apple sort it out as it will surely break loads of SwiftUI apps (including mine).

提交回复
热议问题