self.navigationController.interactivePopGestureRecognizer.enabled = YES;
self.navigationController.interactivePopGestureRecognizer.delegate = nil;
self.navigationController.interactivePopGestureRecognizer.enabled = YES ;
- (void)viewDidAppear:(BOOL)animated{
self.navigationController.interactivePopGestureRecognizer.delegate = (id)self;
}
#pragma mark - UIGestureRecognizerDelegate
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer*)gestureRecognizer{
//判断是否为rootViewController
if (self.navigationController && self.navigationController.viewControllers.count == 1) {
return NO;
}
return YES;
}
UIBarButtonItem *item = [[UIBarButtonItem alloc]init]; item.title = @""; self.navigationItem.backBarButtonItem = item;
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
//代理置空,否则会闪退
if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
self.navigationController.interactivePopGestureRecognizer.delegate = nil;
}
}
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
//开启iOS7的滑动返回效果
if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
//只有在二级页面生效
if ([self.navigationController.viewControllers count] == 2) {
self.navigationController.interactivePopGestureRecognizer.delegate = self;
}
}
}
- (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
//开启滑动手势
if ([navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
navigationController.interactivePopGestureRecognizer.enabled = YES;
}
}
//在切换界面的过程中禁止滑动手势,避免界面卡死
if ([_currentNav respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
_currentNav.interactivePopGestureRecognizer.enabled = NO;
}
[_currentNav pushViewController:viewController animated:YES];
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有