如何在快速滑动推送和弹出视图控制器时保持导航屏幕

时间:2018-11-20 09:40:19

标签: ios swift

我正在研究swipe gesture,并且想同时按住navigation controller并同时使用推视图和弹出视图控制器。使用弹出视图控制器时,此方法效果很好,但按下视图控制器时,不按住navigation controller。有什么解决办法吗?

我的示例代码如下。

//MARK:- Swipe
    func swipeGestures() {
        let swipeRight = UISwipeGestureRecognizer(target: self, action: #selector(dismiss(fromGesture:)))
        swipeRight.direction = .right
        self.view.addGestureRecognizer(swipeRight)

        let swipeLeft = UISwipeGestureRecognizer(target: self, action: #selector(dismiss(fromGesture:)))
        swipeLeft.direction = .left
        self.view.addGestureRecognizer(swipeLeft)
    }

    //MARK:- Swipe Method
    @objc func dismiss(fromGesture gesture: UISwipeGestureRecognizer) {
        if gesture.direction == .left{
            pushOnSwipe("SecondVC", false)
        } else {
            pushOnSwipe("ThirdVC", true)
        }
    }
}

0 个答案:

没有答案