简介
在项目中经常碰到包括自定义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;
}
网友评论