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

相關文章
相關標籤/搜索