不同视图之间的SwiftUI导航

时间:2020-03-09 22:18:19

标签: ios swift xcode modal-dialog swiftui

我们如何在没有模态或Navigationview(列表)方法的情况下在独立屏幕之间导航(无选择返回)?

有没有办法做到这一点?

2 个答案:

答案 0 :(得分:2)

欢迎使用Stackoverflow。是的,有很多方法可以做到这一点。

这篇中篇文章可以为您提供很好的参考: https://medium.com/swlh/customize-your-navigations-with-swiftui-173a72cd8a04

它对modalLink的实现并不那么复杂。

struct ContentView : View {
    @State var isPresented = false

    var body: some View {

        VStack {
            Button(action: {
                print("Button tapped")
                self.isPresented.toggle()
            }) {
               Text("LOGIN")
               .font(.headline)
               .foregroundColor(.white)
               .padding()
               .frame(width: 220, height: 60)
               .background(Color.green)
               .cornerRadius(15.0)
            }
        }.modalLink(isPresented: self.$isPresented, linkType: ModalTransition.fullScreenModal, destination: {
            DestinationView()
        })
    }
}

enter image description here

答案 1 :(得分:-1)

^(?!.*\R\[\d)\[([\d :.-]+)]ERROR.*?(F:\S*)(?:(?!.*Exception|.*\R\[\d).*\R)*+.*\b([a-zA-Z]*Exception)\b

像这样?否则,我会编辑。