【发布时间】:2014-09-01 23:22:26
【问题描述】:
我的故事板如下所示:
我想要实现的是,当在主页上按下“点击我”时,转到“一”,检查这个控制器上的一些逻辑,如果成功,自动转到“二”。
然后,当在“Two”上按下“Back”按钮时,它会将用户带回家,实质上是从堆栈中弹出“One”。
下面是我的“One”控制器的样子:
@implementation OneViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// example logic, in this case just force them to view two
if(1 == 1)
{
[self.navigationController popViewControllerAnimated:NO];
TwoViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"two"];
[self.navigationController pushViewController:vc animated:YES];
}
}
@end
我遇到了奇怪的行为并收到以下错误:
在意外状态下完成导航转换。 导航栏子视图树可能已损坏。
我似乎无法弄清楚我做错了什么。我已经包含了完整的死简单来源:http://andrewherrick.com/spike/pushpop.zip
编辑:
我尝试将逻辑移至 ViewDidAppear,它只是自动将我踢回“主页”视图,这不是我想要的。
- (void)viewDidLoad
{
[super viewDidLoad];
}
-(void)viewDidAppear:(BOOL)animated {
// example logic, in this case just force them to view two
if(1 == 1)
{
[self.navigationController popViewControllerAnimated:NO];
TwoViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"two"];
[self.navigationController pushViewController:vc animated:NO];
}
}
【问题讨论】:
-
嘿,我对 Stroyboard 没有完整的了解,但我确实在基于视图的 UINavigaitonController 中实现了这一点。如果你想知道我可以提供帮助
标签: ios objective-c iphone uinavigationcontroller uistoryboardsegue