禁用ios7 手勢滑動返回功能
阿新 • • 發佈:2019-01-08
在有的時候,我們不需要手勢返回功能,那麼可以在頁面中新增以下程式碼:
- (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; // 禁用 iOS7 返回手勢 if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) { self.navigationController.interactivePopGestureRecognizer.enabled = NO; } } - (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; // 開啟 if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) { self.navigationController.interactivePopGestureRecognizer.enabled = YES; } }