UILongPressGestureRecognizer issue

笑着哭i 提交于 2019-12-20 04:13:25

问题


i have one issue regarding UILongPressGestureRecognizer, i have add gesture like below of the code

**ViewDidLoad**
UILongPressGestureRecognizer *_longRecognizer = [[UILongPressGestureRecognizer alloc]      initWithTarget:self action:@selector(ICN_TRASH_Click:)]; 
NSArray *recognizerArray = [[NSArray alloc] initWithObjects:_longRecognizer, nil];

[[self.view viewWithTag:2001] setGestureRecognizers:recognizerArray];

 OnClick
 if ([sender isKindOfClass:[UILongPressGestureRecognizer class]])  
{

  UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Warning" message:@"Are you sure delete all message ?" delegate:self cancelButtonTitle:@"Yes" otherButtonTitles:@"No",nil];
  [alert show];
  [alert release];

}

So we Long press on button two times call alertview, does anyone have a idea, why facing this issue.


回答1:


So you press the button (then release it I guess) and you are getting the message two times?

Perhaps you should check the state of the GestureRecognizer (like if it's the begin phase or end phase) GestureRecognizer state.



来源:https://stackoverflow.com/questions/3243812/uilongpressgesturerecognizer-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!