1、理解NavigationController返回机制

一般NavigationController下的子view只有一层或者有很多层,子view返回最顶层则可以直接用

[self.navigationController popViewControllerAnimated:YES];

如果NavigationController下有好几层子view,当前子view返回上一层,则可以用

[self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:([self.navigationController.viewControllers count] -2)] animated:YES];

-3为上上一层,依此类推。push和pop的方法类似。

 

2、手势右滑返回上一层

控制器添加代理UIGestureRecognizerDelegate

self.navigationController.interactivePopGestureRecognizer.delegate = self;

- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer{
    
    //判断是否是导航条的第一个子视图控制器
    if (self.navigationController && [self.navigationController.viewControllers count] >= 2) {
        return YES;
    }else{
        return NO;
    }
}

 模态、导航栏混合模式

https://www.cnblogs.com/dingding3w/p/6222626.html

相关文章:

  • 2021-09-25
  • 2022-12-23
  • 2021-12-06
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-04
猜你喜欢
  • 2021-12-04
  • 2021-06-08
  • 2021-10-18
  • 2021-07-06
  • 2021-12-01
  • 2021-08-17
  • 2022-02-08
相关资源
相似解决方案