单击手势同时响应UITapGestureRecognizer事件与TouchBegan事件

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

-(void)touchesBegan:(NSSet *)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事件与TouchBegan事件)