长按时会显示两个操作表
在我的 viewDidLoad 中,我有以下内容:
UILongPressGestureRecognizer *longpressGesture =[[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongpressGesture:)];
longpressGesture.minimumPressDuration = 1;
longpressGesture.allowableMovement = 5;
longpressGesture.numberOfTouchesRequired = 1;
[self.tableView addGestureRecognizer:longpressGesture];
[longpressGesture release];
我创建了以下内容:
-(IBAction) handleLongpressGesture:(UIGestureRecognizer *) sender {
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Delete Record?" delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:@"Yes",@"No",nil];
[actionSheet showInView:self.view];
[actionSheet release];
}
使用模拟器,当我长按时,会显示两个操作表,而不是一个。
关于为什么会这样的任何想法?
是模拟器的问题吗?
Inside my viewDidLoad, I have the following:
UILongPressGestureRecognizer *longpressGesture =[[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongpressGesture:)];
longpressGesture.minimumPressDuration = 1;
longpressGesture.allowableMovement = 5;
longpressGesture.numberOfTouchesRequired = 1;
[self.tableView addGestureRecognizer:longpressGesture];
[longpressGesture release];
I created the following:
-(IBAction) handleLongpressGesture:(UIGestureRecognizer *) sender {
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Delete Record?" delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:@"Yes",@"No",nil];
[actionSheet showInView:self.view];
[actionSheet release];
}
Using the simulator, when I long press, two action sheet shows up instead of the one.
Any ideas as to why this is so?
Is it a problem with the simulator?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不是模拟器的问题。
当手势经历不同的状态(开始、结束等)时,手势处理程序会被多次调用。
您需要在处理程序方法中检查手势的
state
:It's not a problem with the simulator.
The gesture handler is called multiple times as the gesture goes through different states (began, ended, etc).
You need to check the gesture's
state
in the handler method: