UITapGestureRecognizer *doubleTapGestureRecognizer = [[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleDoubleTap:)] autorelease];
doubleTapGestureRecognizer.numberOfTapsRequired = 2;
[self.view addGestureRecognizer:doubleTapGestureRecognizer];
UITapGestureRecognizer *singleTapGestureRecognizer = [[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleTap:)] autorelease];
singleTapGestureRecognizer.numberOfTapsRequired = 1;
// ダブルタップに失敗した時だけシングルタップとする
[singleTapGestureRecognizer requireGestureRecognizerToFail:doubleTapGestureRecognizer];
[self.view addGestureRecognizer:singleTapGestureRecognizer];
More than 5 years have passed since last update.
UITapGestureRecognizerでダブルタップ時にシングルタップアクションをさせない
Last updated at Posted at 2012-09-01
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme