Reputation: 20678
I am developing an application where I have multiple controls on view but I want to enable them when user double tap the view
You can take the example of double click but in device I want to catch the event when their is double tap.
Upvotes: 33
Views: 26781
Reputation: 5120
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
}
}
Upvotes: 78
Reputation: 6958
Add a UITapGestureRecognizer
to the view, with numberOfTapsRequired = 2
.
Upvotes: 8