I have a Subview A(self.thumbnailImageView) added to my superview. I have added a UILongPressGestureRecognizer and UISwipeGestureRecognizer to my subview A.
[self addLongPressGestureRecognizerForPreviewCell:self.thumbnailImageView];
[self addSwipeUpGestureRecognizerForImageView:self.thumbnailImageView];
Now in the handler methods, when the UILongPressGestureRecognizer state begins, i add a Subview B(bigPreviewImage) to my superview(self.view).
-(void)tapGesture:(UILongPressGestureRecognizer *)recognizer{
if (recognizer.state == UIGestureRecognizerStateBegan)
{
// Long press detected, start the timer
[self showPreviewImage:recognizer];
}
else if(recognizer.state == UIGestureRecognizerStateEnded)
{
[self hidePreviewImage];
}
}
-(void)showPreviewImage:(UILongPressGestureRecognizer *)recognizer{
UIImageView *bigPreviewImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Desktop"]];
bigPreviewImage.frame = CGRectMake(self.thumbnailImageView.frame.origin.x - 50.0, self.thumbnailImageView.frame.origin.y + self.thumbnailImageView.frame.size.height + 10.0, 300.0, 250.0);
bigPreviewImage.tag = 10000;//200.0 & 125.0
[bigPreviewImage setUserInteractionEnabled:YES];
[self.view addSubview:bigPreviewImage];
}
Now once the UILongPressGestureRecognizer is active and the user with his finger still pressing the Subview A, If the user swipes up the screen, i want the SwipeGestureRecognizer to get initiated. But the same is not happening. How to initiate a gesture recognizer when a gesture is already active?
I have implemented the shouldRecognizeSimultaneouslyWithGestureRecognizer
method but still the swipe up gesture method is not called. Please let me know if i am missing something.