要在iOS中使用Objective-C编码实现两层返回导航,可以使用以下方法:

  1. 在第一层(根视图控制器)中,将第二层(目标视图控制器)设置为导航控制器的根视图控制器。
TargetViewController *targetVC = [[TargetViewController alloc] init];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:targetVC];
[self presentViewController:navigationController animated:YES completion:nil];
  1. 在第二层(目标视图控制器)中,使用以下代码返回到第一层(根视图控制器)。
[self.navigationController popToRootViewControllerAnimated:YES];

这样,当你在第二层点击返回按钮时,会直接返回到第一层

iOS object-c nav返回2层

原文地址: https://www.cveoy.top/t/topic/iHYQ 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录