tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapGesture:)]; tapGesture.numberOfTapsRequired = 2; tapGesture.numberOfTouchesRequired = 1;
[self.view addGestureRecognizer:tapGesture]; [tapGesture release];
和
- (void)handleTapGesture:(UITapGestureRecognizer *)sender {
if (sender.state == UIGestureRecognizerStateRecognized) {
// handling code
NSLog(@"We got double tap here");
DashBoardViewController* dashboardObj = [[DashBoardViewController alloc] initWithNibName:@"DashBoardViewController" bundle:nil];
[self.navigationController pushViewController:dashboardObj animated:YES];
}
我想做的是,我想在单击和双击时调用 2 个不同的事件。那么我怎样才能检测到 tap==1 和 tap==2 的时间呢?在我的代码中可以识别双击,但我不确定在找到单击时如何查找和工作。
谢谢