UIScorllView的滑动手势 与push方法自带的 或者自己加的侧边放回上一个页面手势
// 自定义UIScrollView, 在里面复制下面代码..
kWidth为屏幕宽度~~~~
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
{
// 判断当前的移动方向 velocity > 0 向右滑 反之...
CGPoint velocity = [(UIPanGestureRecognizer *)gestureRecognizer velocityInView:self];
// 获取手势在屏幕上的初始点
CGPoint location = [gestureRecognizer locationInView:self];
// NSLog(@"velocity.x:%f----location.x:%d",velocity.x,(int)location.x % (int)kWidth);
// 判断一下
if (velocity.x > 0 && (int)location.x % (int)kWidth < 60) {
return NO;
}
return YES;
}
各种有点击方法的空间 例如Button 与手势中轻拍等手势的冲突 只需写一个通知判断一下即可
<span style="font-size:24px;"> </span><span style="font-size:14px;"> NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
[center addObserver:self selector:@selector(closeNotification) name:@"closeUserInteractionEnabled" object:nil];
[center addObserver:self selector:@selector(openNotification) name:@"openUserInteractionEnabled" object:nil];
// 实现通知
- (void)closeNotification
{
for (int i = 0; i < 4; i++) {
UIButton *button = (UIButton *)[View viewWithTag:100 + i];
button.userInteractionEnabled = NO;
}
}
- (void)openNotification
{
for (int i = 0; i < 4; i++) {
UIButton *button = (UIButton *)[_radioMainView viewWithTag:100 + i];
button.userInteractionEnabled = YES;
}
}</span>
<span style="font-size:14px;">
</span>
<span style="font-size:14px;">// 自己应该能判断一下何时需要开启或者关闭交互吧 ....
[[NSNotificationCenter defaultCenter] postNotificationName:@"closeUserInteractionEnabled" object:self userInfo:nil];
[[NSNotificationCenter defaultCenter] postNotificationName:@"openUserInteractionEnabled" object:self userInfo:nil];</span><span style="font-size:24px;">
</span>