gpt4 book ai didi

ios - hidesBarsOnSwipe 禁用左右滑动手势

转载 作者:行者123 更新时间:2023-11-30 13:49:13 31 4
gpt4 key购买 nike

如下面的代码所示,当我添加 hidesBarsOnSwipe 属性时,我的向左和向右滑动功能以某种方式被禁用并且开始不起作用。如何让它们同时工作?

 let leftSwipe = UISwipeGestureRecognizer(target: self, action: Selector("handleSwipes:"))
let rightSwipe = UISwipeGestureRecognizer(target: self, action: Selector("handleSwipes:"))

leftSwipe.direction = .Left
rightSwipe.direction = .Right

view.addGestureRecognizer(leftSwipe)
view.addGestureRecognizer(rightSwipe)

self.navigationController?.hidesBarsOnSwipe = true

最佳答案

   override func viewDidLoad() {
super.viewDidLoad()

var leftSwipe= UISwipeGestureRecognizer(target: self, action: "respondToSwipeGesture:")
swipeRight.direction = UISwipeGestureRecognizerDirection.Left
self.view.addGestureRecognizer(leftSwipe)

var rightSwipe= UISwipeGestureRecognizer(target: self, action: "respondToSwipeGesture:")
swipeDown.direction = UISwipeGestureRecognizerDirection.Right
self.view.addGestureRecognizer(rightSwipe)

self.navigationController?.hidesBarsOnSwipe = false
self.navigationController?.setNavigationBarHidden(false, animated: true)
}

func handleSwipes(gesture: UIGestureRecognizer) {

if let swipeGesture = gesture as? UISwipeGestureRecognizer {
switch swipeGesture.direction {
case UISwipeGestureRecognizerDirection.Right:
print("Swiped right")
case UISwipeGestureRecognizerDirection.Left:
print("Swiped left")
default:
break
}
}

关于ios - hidesBarsOnSwipe 禁用左右滑动手势,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34510732/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com