当我的 hitView 部分来自 UIPanGestureRecognizer 之后的超级视图时,UILongPressGestureRecognizer 不起作用。为什么?
- (id)initWithFrame:(CGRect)frame
{
UIPanGestureRecognizer *panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(pan:)];
[panGesture setMaximumNumberOfTouches:1];
[panGesture setDelegate:self];
[_glassesImage addGestureRecognizer:panGesture];
UILongPressGestureRecognizer *longPressGesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(enchance:)];
longPressGesture.minimumPressDuration = 0.2;
[_glassesImage addGestureRecognizer:longPressGesture];
[self addSubview:_glassesImage];
}
- (void)enchance:(UILongPressGestureRecognizer *)gestureRecognizer
{
UIView *hitView = [gestureRecognizer view];
hitView.alpha=0.6;
inLongPress=YES;
gestureRecognizer.allowableMovement = 200;
if ([gestureRecognizer state] == UIGestureRecognizerStateEnded){
hitView.alpha=1.0;
inLongPress=NO;
}
}