UINavigationController手勢問題

個人習慣,喜歡寫一個子類BaseNavigationController,在BaseNavigationController中寫入下邊的代碼:廢話不多說,看代碼,不解釋

class BaseNavigationController: UINavigationController,UIGestureRecognizerDelegate {


    

    override func viewDidLoad() {

        super.viewDidLoad()


        // Do any additional setup after loading the view.

         self.interactivePopGestureRecognizer!.delegateself

        

    }

    func gestureRecognizerShouldBegin(gestureRecognizer: UIGestureRecognizer) -> Bool

    {

        if (self.viewControllers.count <= 1 ) {

            return false;

        }

        

        return true;

    }


    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 prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {

        // Get the new view controller using segue.destinationViewController.

        // Pass the selected object to the new view controller.

    }

    */

    

    override func pushViewController(viewController: UIViewController, animated: Bool) {

        super.pushViewController(viewController, animated: animated)

        

      

        self.interactivePopGestureRecognizer!.enabled = true

        

    }

    



}



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章