Search code examples
iosswiftuinavigationcontrolleruipangesturerecognizerswrevealviewcontroller

SWRevealViewController panGesture issue - IOS/Swift


In my application I used SWRevealViewController in order to implement the side menu. There, for some reason I had to put a view which is embed in a navigation controller, before the reveal view controller.

This is my storyboard

enter image description here

Everything works fine other than one thing. when I drag from the left edge of the screen to the right side (pan gesture) on my home view, instead of side menu it navigates me to the previous view (in here case to the middle view which contains a button in the middle).

This is how it looks like when dragging

enter image description here

I want to avoid this and get the side menu when dragging like that. Can someone help me on this. Any help would be highly appreciated.

Edit:

This is the front_view and rear_view

enter image description here


Solution

  • Take a ViewController.swift file for the initial ViewController having button.

    class ViewController: UIViewController {
    
        override func viewDidLoad() {
            super.viewDidLoad()
    
            // Do any additional setup after loading the view.
        }
    
        override func viewDidAppear(_ animated: Bool) {
            super.viewDidAppear(animated)
            self.navigationController?.interactivePopGestureRecognizer?.isEnabled = false
    
        }
    
        override func didReceiveMemoryWarning() {
            super.didReceiveMemoryWarning()
            // Dispose of any resources that can be recreated.
        }
    
    
        /*
        // MARK: - Navigation
    
        // In a storyboard-based application, you will often want to do a little preparation before navigation
        override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
            // Get the new view controller using segue.destinationViewController.
            // Pass the selected object to the new view controller.
        }
        */
    
    }
    

    There is no issue in the swrevealviewcontroller implementation but the native behavior of navigation controller is causing this issue.