解决一级页面侧滑卡死问题

很早遇到的问题,最初是在一级页面里去关闭手势,离开时开启手势,之后重构就是用Method Swizzling,很快就解决了问题:

+ (void)load {

    Method oldMethod =class_getInstanceMethod(self,@selector(viewWillAppear:));

    Method newMethod =class_getInstanceMethod(self,@selector(BSY_viewWillAppear:));

    method_exchangeImplementations(oldMethod, newMethod);

}

- (void)BSY_viewWillAppear:(BOOL)animated

{

    [self BSY_viewWillAppear:animated];

    self.navigationController.interactivePopGestureRecognizer.delegate = (id)self;

}

- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer*)gestureRecognizer {

    return !(self == self.navigationController.viewControllers.firstObject);

}

你可能感兴趣的:(解决一级页面侧滑卡死问题)