iOS 关于NavigationController返回的一些笔记

一、理解NavigationController返回机制html

通常NavigationController下的子view只有一层或者有不少层,子view返回最顶层则能够直接用spa

[self.navigationController popViewControllerAnimated:YES];

若是NavigationController下有好几层子view,当前子view返回上一层,则能够用代理

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

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

 

二、手势右滑返回上一层htm

控制器添加代理UIGestureRecognizerDelegateblog

self.navigationController.interactivePopGestureRecognizer.delegate = self;

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

 模态、导航栏混合模式io

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

相关文章
相关标签/搜索