注意: 这里主要是对于scrollView和返回手势的冲突处理
- 效果图如下:
- 全屏右滑pop返回请看 <a href="http://www.jianshu.com/p/e183689ae80a">iOS开发: 导航控制器 - 全屏右滑pop返回效果</a>
具体步骤
- 第一步: 定义LTScrollView类, 继承自UIScrollView
- 第二部: 重写scrollView的<a>-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer</a>方法即可
- 具体代码如下
#import "LTScrollView.h"
@interface LTScrollView () <UIGestureRecognizerDelegate>
@end
@implementation LTScrollView
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
// 首先判断otherGestureRecognizer是不是系统pop手势
if ([otherGestureRecognizer.view isKindOfClass:NSClassFromString(@"UILayoutContainerView")]) {
// 再判断系统手势的state是began还是fail,同时判断scrollView的位置是不是正好在最左边
if (otherGestureRecognizer.state == UIGestureRecognizerStateBegan && self.contentOffset.x == 0) {
return YES;
}
}
return NO;
}
@end
- 最后, 只需要将使用的UIScollView类型换成LTScrollView类型即可