首页 > UINavigation代理问题.

UINavigation代理问题.

今天在学习UInavigationController的时候,通过NavigationViewController把RootViewController作为根视图赋值给window.rootViewController.

    RootViewController * rootC = [[RootViewController alloc] init];
    UINavigationController * naviVC = [[UINavigationController alloc] initWithRootViewController:rootC];
    
    self.window.rootViewController = naviVC;

然后我在RootViewController当中,设置self.NavigationViewController.delegate = self;

接着我设置一个新的MainViewController,然后从RootViewController用按钮触发方法调用:[self.navigationController pushViewController:mainVC animated:YES];
跳转到MainViewController.

我这边需要两个页面循环跳转.所以又在MainViewController中设置一个按钮触发方法: [self.navigationController pushViewController:rootVC animated:YES];跳转到RootViewController.

所以,跳转后压栈变成:(

"<RootViewController: 0x7fbf88541870>",
"<MainViewController: 0x7fbf88498c90>",
"<RootViewController: 0x7fbf8856c300>",
"<MainViewController: 0x7fbf88590270>",
...

)

如果是这样,就会在push了两个(或者更多的)页面之后,用 [self.navigationController popViewControllerAnimated:YES];方法pop了2次或者3次的时候,就会崩溃了.

但是push一个页面,再pop一个页面,是不会崩溃的.

请教各位大神,有没遇到这种情况的??

还有,这是为什么啊??

【热门文章】
【热门文章】