在我们的 iOS 应用程序中,有三个UIViewController
一个接着一个,我们想根据某些条件跳过中间的,直接从第一到第三。但是,用户应该能够通过第三个控制器上的“后退”按钮返回到第二个控制器。
I tried [self performSegueWithIdentifier:@"segueId" sender:sender];
from viewDidLoad
, viewWillAppear
但这会损坏导航栏,如调试日志所示。从调用此代码viewDidAppear
工作正常,但第二个视图已经显示,这是我首先试图避免的。
我也尝试过[self.navigationController pushViewController:vc animated:NO];
但结果同样损坏了导航栏,即使这次调试日志没有此类条目。
支持的方式是什么(如果可能的话)?
目标是带有 iOS 5.1 的 iPhone4,开发环境是 Xcode 4.3。
我在应用程序中使用以下代码。完全按照预期工作。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
SecondViewController *secondVC = [self.storyboard instantiateViewControllerWithIdentifier:@"DetailViewController"];
if (indexPath.row == 0) {
// skip second vc
ThirdViewController *thirdVC = [self.storyboard instantiateViewControllerWithIdentifier:@"ThirdViewControllerViewController"];
[self.navigationController pushViewController:secondVC animated:NO];
[self.navigationController pushViewController:thirdVC animated:YES];
}
else {
// push second vc
[self.navigationController pushViewController:secondVC animated:YES];
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)