无意间看到文明大神的 ScreenShotBack的 全屏返回,截图手势返回,景深效果,类似斗鱼、天天快报、腾讯新闻等APP的手势返回。
感觉实现的效果非常好, 本人非常喜欢今日头条也喜欢他的全屏返回手势的效果
先来体验一下文明大神的效果
文明效果.gif效果非常好, 但是有一个待完善的东西是: 我们在全屏返回详情页面的时候,发现tableView的数据可以上下滑动, 这是我们不愿意看到的
自己针对这种情况做了修改
BaseNavigationController.m
中的
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
NSLog(@"shouldRecognizeSimultaneouslyWithGestureRecognizer---%@", otherGestureRecognizer);
if ([otherGestureRecognizer isKindOfClass:NSClassFromString(@"UIScrollViewPanGestureRecognizer")] || [otherGestureRecognizer isKindOfClass:NSClassFromString(@"UIPanGestureRecognizer")]|| [otherGestureRecognizer isKindOfClass:NSClassFromString(@"UIScrollViewPagingSwipeGestureRecognizer")]){
//冲突要有两个,二者不可兼得
UIView *aView = otherGestureRecognizer.view;
if ([aView isKindOfClass:[UIScrollView class]] && [otherGestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]]) {
UIScrollView *sv = (UIScrollView *)aView;
CGFloat svWidth = sv.contentSize.width;
NSInteger subViewsNum = svWidth/[UIScreen mainScreen].bounds.size.width;
UIPanGestureRecognizer *panGest = (UIPanGestureRecognizer *)otherGestureRecognizer;
CGPoint translation = [panGest translationInView:self.view];
//设置左滑和右滑的情况
// 右滑的情况
if (translation.x > 0){
// 如果是scrollView多视图 类似附近 广场 推荐的滚动
if((sv.contentOffset.x==0) && (subViewsNum > 1) ){
return YES;
}
}else{
// tableView的左滑
if ((sv.contentOffset.x==0) && (subViewsNum == 1)){
return YES;
}
}
}
}
return NO;
}
转机
联系到作者文明大神, 给出了较好的解决方案。
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
NSLog(@"shouldRecognizeSimultaneouslyWithGestureRecognizer---%@", otherGestureRecognizer);
if ([otherGestureRecognizer isKindOfClass:NSClassFromString(@"UIScrollViewPanGestureRecognizer")] || [otherGestureRecognizer isKindOfClass:NSClassFromString(@"UIPanGestureRecognizer")]|| [otherGestureRecognizer isKindOfClass:NSClassFromString(@"UIScrollViewPagingSwipeGestureRecognizer")]){
//冲突要有两个,二者不可兼得
UIView *aView = otherGestureRecognizer.view;
if ([aView isKindOfClass:[UIScrollView class]] && [otherGestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]]) {
UIScrollView *sv = (UIScrollView *)aView;
//设置左滑和右滑的情况
// 右滑的情况
// 如果是scrollView多视图 类似附近 广场 推荐的滚动
if([sv isKindOfClass:[UITableView class]]){
return NO;
}
// 如果是scrollView多视图 类似附近 广场 推荐的滚动
if(sv.contentOffset.x==0){
return YES;
}
}
}
return NO;
}
感觉现在我们解决方法 并不好 所以还望各位大神可以给出指导意见! 小弟不胜感激! 修改后的代码在我的gitHub上 SmallTwoInn/ScreenShotBack
晚上吧自己修改这个问题的心理路程好好记录下!
网友评论