RTRootNavigationController icon indicating copy to clipboard operation
RTRootNavigationController copied to clipboard

会不会和这个FDFullscreenPopGesture的第三方 有冲突 造成卡死?

Open chenyingchao opened this issue 7 years ago • 6 comments
trafficstars

同时使用了 RTRootNavigationController FDFullscreenPopGesture

APP出现过 卡死 、VC的层级乱了的问题

chenyingchao avatar Jun 29 '18 09:06 chenyingchao

#166

faimin avatar Jun 29 '18 09:06 faimin

@faimin @rickytan 想要单手势 就重写父类中的方法? 会不会造成影响?

//子类
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
    
    return NO;
}


父类RTRootNavigationController
#pragma mark - UIGestureRecognizerDelegate

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
  
    return YES;
}

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer
shouldBeRequiredToFailByGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
    return (gestureRecognizer == self.interactivePopGestureRecognizer);
}

chenyingchao avatar Jun 29 '18 09:06 chenyingchao

想要某个页面无法滑动返回 添加全屏返回以后 self.rt_disableInteractivePop = YES 就无效了

chenyingchao avatar Jun 29 '18 10:06 chenyingchao

FDFullscreenPopGesture 使用了太多 swizzle ,而同时本项目有两层 Navigation,难免出问题。 你的全屏返回怎么做的?

rickytan avatar Jun 29 '18 14:06 rickytan

    // 获取系统自带滑动手势的target对象
    id target = self.interactivePopGestureRecognizer.delegate;
    // 创建全屏滑动手势,调用系统自带滑动手势的target的action方法
    SEL internalAction = NSSelectorFromString(@"handleNavigationTransition:");
    UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:target action:internalAction];
    // 设置手势代理,拦截手势触发
    pan.delegate = self;
    // 给导航控制器的view添加全屏滑动手势
    [self.view addGestureRecognizer:pan];
    // 禁止使用系统自带的滑动手势
    self.interactivePopGestureRecognizer.enabled = NO;



- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
{
    // 注意:只有非根控制器才有滑动返回功能,根控制器没有。
    // 判断导航控制器是否只有一个子控制器,如果只有一个子控制器,肯定是根控制器
    if (self.childViewControllers.count == 1) {
        // 表示用户在根控制器界面,就不需要触发滑动手势,
        return NO;
    }
    
    if (self.childViewControllers.count) {
        if ([self.childViewControllers.lastObject isKindOfClass:[RTContainerController class]]) {
             RTContainerController *vc = self.childViewControllers.lastObject;
            if (vc.contentViewController.rt_disableInteractivePop) {
                return NO;
            }
        }
    }
    return YES;
}

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
    
    return NO;
}

chenyingchao avatar Jul 26 '18 05:07 chenyingchao

你的 self.childViewControllers.lastObject 改为 self.topViewController 试试?

rickytan avatar Jul 27 '18 15:07 rickytan