Reputation: 832
I am using UILongPressGestureRecognizer in my collection view, i want long press gesture recogniser should work only if certain condition is met.
NSString *check;
if([check isEqualToString:@"Enabled"]
{
//long press should be detected. or following method should be called
}
-(void)handleLongPressGesture:(UILongPressGestureRecognizer *)gestureRecognizer
{
}
Upvotes: 0
Views: 70
Reputation: 341
NSString *check;
UILongPressGestureRecognizer *longPress =[ [UILongPressGestureRecognizer alloc]init];
if([check isEqualToString:@"Enabled"]
{
UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc]
initWithTarget:self
action:@selector(handleLongPressGesture:)];
}else{
}
-(void)handleLongPressGesture:(UILongPressGestureRecognizer *)gestureRecognizer
{
}
Upvotes: 1
Reputation: 701
Add UIGestureRecognizerDelegate
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer{
NSString *check;
if([check isEqualToString:@"Enabled"]
{
//long press should be detected. or following method should be called
return YES;
}else{
return NO;
}
}
Upvotes: 1