我正在研究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)
}
}
}