我有 3 个 VC( View Controller )(VC1、VC2、VC3)。
在 VC1,我使用了代码:
self.navViewController = [[UINavigationController alloc] initWithRootViewController:viewController];
self.navViewController.view.frame = CGRectMake(self.view.frame.size.width - viewController.view.frame.size.width,
viewController.view.frame.origin.y,
viewController.view.frame.size.width,
viewController.view.frame.size.height);
[self.navigationController addChildViewController:self.navViewController];
[self.navigationController.view addSubview:self.navViewController.view];
[self.navViewController didMoveToParentViewController:self.navigationController];
正在显示 VC2,然后在 VC2 我使用代码将导航 Controller 推送到 VC3
VC3 *vc3 = [[VC3 alloc] initWithNibName:@"VC3" bundle:nil];
[vc3.view updateConstraintsIfNeeded];
[self.navigationController pushViewController:vc3 animated:YES];
目前,当我添加片段代码时 [vc3.view updateConstraintsIfNeeded];
。我看到更改的导航和内容 View 没有更改和显示。它只是显示 VC2 的内容 View 。
在我的项目中,我使用了自动布局。我尝试在我的项目中删除自动布局,效果很好。当我添加自动布局时,它工作不正常。
它只发生在 iOS 7 上,iOS 8 运行良好。
请帮我解决这个错误。非常感谢!
最佳答案
问题是您正在推送的 View Controller 之上显示 VC2。将一个 View Controller 作为导航 Controller 的子级的原因是什么?相反,VC2 和导航 Controller 有一个共同的祖先,或者将 VC2 放在 View 层次结构中的其他位置,而不是放在导航 Controller 的 view
之上,后者保存着整个导航 Controller (包括包含在推送堆栈中的 Controller ) View 层次结构。
关于ios - 推送 View Controller 未在 ios 7 上推送,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31169518/