判断UIViewController是使用pop,dismiss返回到上级视图控制器

判断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];
    }
    
}
        

你可能感兴趣的:(判断UIViewController是使用pop,dismiss返回到上级视图控制器)