首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >覆盖UIGestureRecognizer touchesBegan

覆盖UIGestureRecognizer touchesBegan
EN

Stack Overflow用户
提问于 2014-10-22 11:13:19
回答 1查看 4.8K关注 0票数 6

我有一个主视图和一个SubView

主视图> SubView

我认为主要观点是“窃取”SubView的事件。

例如,当我点击SubView时,只有主视图GestureRecognizer是fire。

下面是我的自定义GestureRecognizer (它拦截每个触摸事件):

代码语言:javascript
复制
import UIKit
import UIKit.UIGestureRecognizerSubclass

class MainGestureRecognizer: UIGestureRecognizer {
    
    override func touchesBegan(touches: NSSet!, withEvent event: UIEvent!) {
        super.touchesBegan(touches, withEvent: event);
        //nextResponder() ??
        
        state = UIGestureRecognizerState.Began;
    }
 
    override func touchesMoved(touches: NSSet!, withEvent event: UIEvent!) {
        super.touchesMoved(touches, withEvent: event);
        //nextResponder() ??
        
        state = UIGestureRecognizerState.Changed;
    }
 
    override func touchesEnded(touches: NSSet!, withEvent event: UIEvent!) {
        super.touchesEnded(touches, withEvent: event);
        //nextResponder() ??
        
        state = UIGestureRecognizerState.Ended;
    }
 
    override func touchesCancelled(touches: NSSet!, withEvent event: UIEvent!) {
        super.touchesCancelled(touches, withEvent: event);
        //nextResponder() ??
        
        state = UIGestureRecognizerState.Cancelled;
    }
}

也许我应该使用nextResponder,,但我只找到了这样的Obj代码:

self.nextResponder触控贝根:触碰事件:事件; What's the trick to pass an event to the next responder in the responder chain? Is there a way to pass touches through on the iPhone?

所以问题是,我应该怎么做才能让第二个事件( SubView事件)也发生呢?

在Swift中有像nextResponder这样的函数吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-10-22 16:46:17

快跳啊!以下是nextResponder的Swift代码:

https://stackoverflow.com/a/26510277/4135158

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26506148

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档