开启此功能-----
- (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; // 在此决定是否开启左侧侧滑返回功能 if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) { self.navigationController.interactivePopGestureRecognizer.delegate = nil; self.navigationController.interactivePopGestureRecognizer.enabled = self.navigationController.viewControllers.count - 1; } }
关闭此功能-----
- (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; // 在此决定是否开启左侧侧滑返回功能 if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) { self.navigationController.interactivePopGestureRecognizer.enabled = NO; } }
本文介绍了如何在iOS应用中通过代码控制左侧侧滑返回功能的开启与关闭,提供了具体的方法实现,包括在viewDidAppear方法中判断并设置navigationController的interactivePopGestureRecognizer属性。
377

被折叠的 条评论
为什么被折叠?



