美文网首页
单击手势同时响应UITapGestureRecognizer事件

单击手势同时响应UITapGestureRecognizer事件

作者: 离离乱惑 | 来源:发表于2017-02-13 16:30 被阅读180次

    在View上添加一个单击手势及其响应事件,如果有写

    -(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
    

    会先响应touchesBegan,再响应单击手势的事件。
    要阻止touchesBegan的响应,只需要将手势的delaysTouchesBegan属性设置为Yes。
    避免在识别出点击手势之前出发touches手势

    @property(nonatomic) BOOL delaysTouchesBegan;         
    // default is NO.  causes all touch or press events to be delivered to 
    the target view only after this gesture has failed recognition. set to 
    YES to prevent views from processing any touches or presses that may be 
    recognized as part of this gesture
    

    相关文章

      网友评论

          本文标题:单击手势同时响应UITapGestureRecognizer事件

          本文链接:https://www.haomeiwen.com/subject/wuhtwttx.html