Programmatically go back to previous ViewController in Swift

前端 未结 15 1534
野的像风
野的像风 2020-12-04 04:50

I send the user over to a page on a button click. This page is a UITableViewController.

Now if the user taps on a cell, I would like to push him ba

15条回答
  •  一生所求
    2020-12-04 05:43

    This one works for me (Swift UI)

    struct DetailView: View {
    @Environment(\.presentationMode) var presentationMode: Binding
    
      var body: some View {
          VStack {
            Text("This is the detail view")
            Button(action: {
              self.presentationMode.wrappedValue.dismiss()
            }) {
              Text("Back")
            }
          }
        }
    }
    

提交回复
热议问题