gpt4 book ai didi

ios - shouldReceiveTouch 未触发

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

我试图从我的 TapGestureRecognizer 中排除 subview 。它已在sotryboard中创建,委托(delegate)已连接到 Controller 。

在我的 ViewControler 中,我有 GestureRecognizerDelegate 协议(protocol),并且我设置了gesture.delegate = self。

虽然 shouldReceiveTouch Gesturerecognizer 函数没有调用,但有什么想法吗?

这是一些代码:

class DetailedPostViewController: UIViewController, UITextViewDelegate, MKMapViewDelegate, UIGestureRecognizerDelegate {


let circularLike = CircularLike(frame: CGRectZero)

@IBOutlet var gesture: UITapGestureRecognizer!

override func viewDidLoad() {

super.viewDidLoad()

gesture.delegate = self

self.view.addSubview(circularLike)
circularLike.frame = self.view.bounds

}


func gestureRecognizer(gestureRecognizer: UIGestureRecognizer, shouldReceiveTouch touch: UITouch) -> Bool {
if touch.view!.isDescendantOfView(circularLike){
return false
}
return true
}

@IBAction func UserTap(sender: AnyObject) {
if fromUser {
dismissViewControllerAnimated(true, completion: nil)
} else {
performSegueWithIdentifier("userPage", sender: nil)
}
}



@IBAction func hideUnhide(sender: UIGestureRecognizer) {
if hide {
hide=false
unhideUi()
} else {
hide = true
hideUi()
}
}

}

最佳答案

好吧,事实上,我只需将 subview 的 userTouchEnabled 参数设置为 false,然后它就会触发 ShouldRecieveTouch 函数...

关于ios - shouldReceiveTouch 未触发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36255880/

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