0

Default for detail Screen UIViewController (swipe / click back button) its goes its previous controller, i.e., its RootviewController

When added custom back button to detail UIViewController swipe stop working, only click back button works.

why its like that? how to enable the swipe option too for navigating its previous controller.

CustomViewController

override func viewDidLoad() {
    super.viewDidLoad()

    // Do any additional setup after loading the view.

    self.navigationItem.leftBarButtonItem = UIBarButtonItem.menuButton(self, action: #selector(backButtonPressed), imageName: "backArrow")

}

@objc func backButtonPressed() {

   // self.navigationController?.popToRootViewController(animated: true)
    navigationController?.popViewController(animated: true)

}

DetailViewController

class DetailViewController: CustomViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
kiran
  • 4,285
  • 7
  • 53
  • 98
  • Its works, but when do a swipe gesture right, on MainViewController which do not have any back button, then try to navigate to DetailViewController then application stuck. – kiran May 19 '20 at 23:05
  • override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) self.navigationController?.interactivePopGestureRecognizer?.delegate = self self.navigationController?.delegate = self } – kiran May 19 '20 at 23:09

0 Answers0