Navigation pop view when swipe right like Instagram iPhone app.How i achieve this?

前端 未结 5 875
有刺的猬
有刺的猬 2020-12-02 10:48

I want to pop a view when swipe right on screen or it\'s work like back button of navigation bar.

I am using:

self.navigationController.interactivePo         


        
5条回答
  •  伪装坚强ぢ
    2020-12-02 11:28

    Create a pan gesture recogniser and move the interactive pop gesture recogniser's targets across.

    Add your recogniser to the pushed view controller's viewDidLoad and voila!

    let popGestureRecognizer = self.navigationController!.interactivePopGestureRecognizer!
    if let targets = popGestureRecognizer.value(forKey: "targets") as? NSMutableArray {
      let gestureRecognizer = UIPanGestureRecognizer()
      gestureRecognizer.setValue(targets, forKey: "targets")
      self.view.addGestureRecognizer(gestureRecognizer)
    }
    

提交回复
热议问题