我有一个关于UILongPressGestureRecognizer的问题,我添加了代码下面的手势
**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];
}
所以我们长按两次按钮调用alertview, 有没有人有一个想法,为什么要面对这个问题。
答案 0 :(得分:2)
所以你按下按钮(然后我猜它就释放了)你得到了两次消息?
也许您应该检查GestureRecognizer的状态(如果它是开始阶段或结束阶段)GestureRecognizer state。