To use UILongPressGestureRecognizer, you can do something like this:
UILongPressGestureRecognizer* recognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPressFrom:)]; recognizer.minimumPressDuration = 2.0;
Your long print handler might look like this:
-(void)handleLongPressFrom:(UILongPressGestureRecognizer*)recognizer { if(recognizer.state == UIGestureRecognizerStateEnded) { CCLOG(@"Long press gesture recognized.");
When you are done, be sure to remove it.
AppDelegate* appDelegate = [[UIApplication sharedApplication] delegate]; [appDelegate.viewController.view removeGestureRecognizer:recognizer];
source share