I\'m using the UILongPressGestureRecognizer in a cell. What I need is: when a user taps a cell for 1.0 seconds, call one view controller. If the user taps the cell, another
Instead of disabling it, what you probably need to do is check the gesture recognizer's state
property and only display the next view controller if the state is UIGestureRecognizerStateBegan
(or UIGestureRecognizerStateEnded
).
You'll need to change your method to accept the gesture recognizer as a parameter (and also update the @selector
parameter) and check it's state:
UILongPressGestureRecognizer *longPressTap =
[[UILongPressGestureRecognizer alloc] initWithTarget:self
action:@selector(memberListWithSearchOptions:)]; //colon at end
//...
- (void)memberListWithSearchOptions:(UILongPressGestureRecognizer *)lpt
{
if (lpt.state == UIGestureRecognizerStateBegan)
//or check for UIGestureRecognizerStateEnded instead
{
//display view controller...
}
}
You have to check state as below
- (void)memberListWithSearchOptions:(UILongPressGestureRecognizer*)sender {
if (sender.state == UIGestureRecognizerStateEnded) {
NSLog(@"UIGestureRecognizerStateEnded");
//Do Whatever You want on End of Gesture
}
else if (sender.state == UIGestureRecognizerStateBegan){
NSLog(@"UIGestureRecognizerStateBegan.");
//Do Whatever You want on Began of Gesture
}