Objective-c: How to detect double tap on view?
You need to add an UITapGestureRecognizer
to the view which you want to be tapped.
Like this:
- (void)viewDidLoad { [super viewDidLoad]; UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapGesture:)]; tapGesture.numberOfTapsRequired = 2; [self.view addGestureRecognizer:tapGesture]; [tapGesture release];}- (void)handleTapGesture:(UITapGestureRecognizer *)sender { if (sender.state == UIGestureRecognizerStateRecognized) { // handling code }}
Add a UITapGestureRecognizer
to the view, with numberOfTapsRequired = 2
.