iOS开发程序员

iOS 同一个控件单击手势和双击手势事件冲突

2019-05-28  本文已影响6人  风规自远

/*单击*/ 

UITapGestureRecognizer* singleRecognizer;    

singleRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(singleRecognizerTap:)];    

/*单击    -------    点击的次数*/ 

singleTapRecognizer.numberOfTapsRequired = 1; 

[self.view addGestureRecognizer:singleRecognizer];   

/*双击的 Recognizer*/

UITapGestureRecognizer* doubleRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(doubleRecognizerTap:)];    

/*双击*/ 

doubleRecognizer.numberOfTapsRequired = 2;   

[self.view addGestureRecognizer:doubleRecognizer];    

/**

*    双击手势确定监测失败才会触发单击手势的相应操作    

*/

[singleRecognizer requireGestureRecognizerToFail:doubleRecognizer];   


上一篇下一篇

猜你喜欢

热点阅读