iOS滑动返回手势失效解决方案

2018-12-26  本文已影响0人  sheldon_龙

简介

在项目中经常碰到包括自定义backBarItem和隐藏navigationbar导致返回手势失效的问题,这里给出如下解决方案。

@interface ZYLViewController ()
@property (strong,nonatomic) UINavigationController *navController;
@property (strong,nonatomic) id interactivePopGestureRecognizerDelete;
@end

@implementation ZYLViewController


- (void)viewDidLoad {
[super viewDidLoad];
self.navController=self.navigationController;
self.interactivePopGestureRecognizerDelete =        self.navigationController.interactivePopGestureRecognizer.delegate;
}

-(void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
self.navController.interactivePopGestureRecognizer.delegate = nil;
}
-(void)viewWillDisappear:(BOOL)animated{
[super viewWillDisappear:animated];

self.navController.interactivePopGestureRecognizer.delegate = self.interactivePopGestureRecognizerDelete;
}

上一篇下一篇

猜你喜欢

热点阅读