如何禁掉UIScrollView里的UIPanGestureRecognizer
1个回答
推荐于2016-01-22
展开全部
举例说明:
首先添加手势识别,并给手势识别指定代理
⋯⋯
UIPanGestureRecognizer* panRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:selfaction:@selector(handlePanGesture:)];
[panRecognizer setMaximumNumberOfTouches:1];
[panRecognizer setDelaysTouchesBegan:TRUE];
[panRecognizer setDelaysTouchesEnded:TRUE];
[panRecognizer setCancelsTouchesInView:TRUE];
//为手势识别器设置代理
panRecognizer.delegate = self;
[self.view addGestureRecognizer:panRecognizer];
[panRecognizer release];
⋯⋯
然后,实现UIGestureRecognizerDelegate的方法:
// 当拖动UISlider时会被误认为是手势,所以在这个判断一下
-(BOOL)gestureRecognizer:(UIGestureRecognizer*)gestureRecognizer shouldReceiveTouch:(UITouch*)touch {
if([touch.view isKindOfClass:[UISlider class]])
return NO;
else
return YES;
}
首先添加手势识别,并给手势识别指定代理
⋯⋯
UIPanGestureRecognizer* panRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:selfaction:@selector(handlePanGesture:)];
[panRecognizer setMaximumNumberOfTouches:1];
[panRecognizer setDelaysTouchesBegan:TRUE];
[panRecognizer setDelaysTouchesEnded:TRUE];
[panRecognizer setCancelsTouchesInView:TRUE];
//为手势识别器设置代理
panRecognizer.delegate = self;
[self.view addGestureRecognizer:panRecognizer];
[panRecognizer release];
⋯⋯
然后,实现UIGestureRecognizerDelegate的方法:
// 当拖动UISlider时会被误认为是手势,所以在这个判断一下
-(BOOL)gestureRecognizer:(UIGestureRecognizer*)gestureRecognizer shouldReceiveTouch:(UITouch*)touch {
if([touch.view isKindOfClass:[UISlider class]])
return NO;
else
return YES;
}
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询