判断UIViewController是使用pop,dismiss

2020-12-04  本文已影响0人  文子飞_

判断UIViewController返回时使用 pop 的方法,还是使用dismiss 的方法了。

- (void)backAction {
    
    NSLog(@"presentingViewController = %@", self.presentingViewController);
    
    NSLog(@"self.navigationController.topViewController = %@", self.navigationController.topViewController);
    NSLog(@"self.navigationController.viewControllers.count = %ld", self.navigationController.viewControllers.count);
    
    if (self.presentingViewController) {
        [self dismissViewControllerAnimated:YES completion:nil];
    } else if (self.navigationController.viewControllers.count > 2 || self.navigationController.topViewController == self) {
        [self.navigationController popViewControllerAnimated:YES];
    }
    
}
        
上一篇下一篇

猜你喜欢

热点阅读