手机直播源码,导航栏侧滑手势启用/禁用弃用正确姿势
一般我们如此设置手势侧滑(1.先建一个NAV的子类.然后重写Push方法)
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated {
if (self.viewControllers.count >= 1) {
viewController.hidesBottomBarWhenPushed = YES;
[super pushViewController:viewController animated:animated];
viewController.navigationController.interactivePopGestureRecognizer.enabled = YES;
} else {
[super pushViewController:viewController animated:animated];
}
}
因为count = 0的话没有上一级.这时候如果还允许侧滑就崩溃.然而如果我们自定义了导航栏的leftbarbutonitem.那么侧滑手势还是失效.
这是因为我们的viewController.navigationController.interactivePopGestureRecognizer.delegate被重置了.所以应该修改为如下代码
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated {
if (self.viewControllers.count >= 1) {
viewController.hidesBottomBarWhenPushed = YES;
[super pushViewController:viewController animated:animated];
viewController.navigationController.interactivePopGestureRecognizer.enabled = YES;
viewController.navigationController.interactivePopGestureRecognizer.delegate = nil;
} else {
[super pushViewController:viewController animated:animated];
}
}
以上就是手机直播源码,导航栏侧滑手势启用/禁用弃用正确姿势, 更多内容欢迎关注之后的文章
标签:pushViewController,弃用,侧滑,viewController,源码,animated,super From: https://www.cnblogs.com/yunbaomengnan/p/17838626.html