SwiftUI: NavigationDestinationLink deprecated

前端 未结 5 534
有刺的猬
有刺的猬 2020-12-01 09:54

After installing Xcode 11 beta 5 this morning, I noticed that NavigationDestinationLink was deprecated in favor of NavigationLink.

Also, t

5条回答
  •  一生所求
    2020-12-01 10:26

    To improve the workaround without replacing the back button with a custom one, you can use the code above :

    NavigationLink(destination: Test().onAppear(perform: {
        self.editPushed = nil
    }), tag: 1, selection: self.$editPushed) {
        Button(action: {
            self.editPushed = 1
        }) {
            Image(systemName: "plus.app.fill")
                .font(.title)
        }
    }
    

    The onAppear block will erase the selection value preventing to display the detail view twice

提交回复
热议问题