UILongPressGestureRecognizer问题 [英] UILongPressGestureRecognizer issue
本文介绍了UILongPressGestureRecognizer问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个关于UILongPressGestureRecognizer的问题,我已添加如下代码的手势
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];
}
所以我们长按两次按钮调用alertview,
有没有人有想法,为什么要面对这个问题。
So we Long press on button two times call alertview, does anyone have a idea, why facing this issue.
推荐答案
所以你按下按钮(然后释放它我猜并且你得到了两次消息?
So you press the button (then release it I guess) and you are getting the message two times?
也许你应该检查GestureRecognizer的状态(如果它是开始阶段或结束阶段) GestureRecognizer state 。
Perhaps you should check the state of the GestureRecognizer (like if it's the begin phase or end phase) GestureRecognizer state.
这篇关于UILongPressGestureRecognizer问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文