我有一个子视图 A(self.thumbnailImageView) 添加到我的超级视图中。我在我的子视图 A 中添加了一个 UILongPressGestureRecognizer 和 UISwipeGestureRecognizer。
[self addLongPressGestureRecognizerForPreviewCell:self.thumbnailImageView];
[self addSwipeUpGestureRecognizerForImageView:self.thumbnailImageView];
现在在处理程序方法中,当 UILongPressGestureRecognizer 状态开始时,我将 Subview B(bigPreviewImage) 添加到我的 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];
}
现在,一旦 UILongPressGestureRecognizer 处于活动状态并且用户的手指仍在按下 Subview A,如果用户向上滑动屏幕,我希望 SwipeGestureRecognizer 启动。但同样的事情并没有发生。当手势已经激活时如何启动手势识别器?
我已经实现了该shouldRecognizeSimultaneouslyWithGestureRecognizer
方法,但仍然没有调用向上滑动手势方法。如果我遗漏了什么,请告诉我。