美文网首页
解决一级页面侧滑卡死问题

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

作者: 口厄 | 来源:发表于2019-04-03 15:40 被阅读0次

很早遇到的问题,最初是在一级页面里去关闭手势,离开时开启手势,之后重构就是用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);

}

相关文章

网友评论

      本文标题:解决一级页面侧滑卡死问题

      本文链接:https://www.haomeiwen.com/subject/gidzbqtx.html