在我的应用程序中,第一个 View 是一个 UIView,带有几个 uilabel 和一个 uibutton 来进行登录。 我想在登录后显示一个带有表格的 uinavigationcontroller ,因此可以使用按钮的操作。 我知道如何从 Xcode 模板开始设置一个工作导航 Controller ,但我不知道如何将其加载为“第二个 View ”
有什么帮助吗?
最佳答案
您可以将 UINavigationController 的 View 添加到 UIWindow 中,并让它遮盖第一个 View 或从 UIWindow 中删除该 View 。 navigationController 没有后退按钮来带您返回第一个 View (因为它的堆栈不包含第一个 Controller ),因此如果您想提供返回方式,则需要一个自定义按钮。
- (IBAction) buttonPressed {
myNavigationController = [[UINavigationController alloc] initWithRootViewController:mySecondViewController];
[self.view.window addSubview:myNavigationController.view];
[self.view removeFromSuperview];
}
这是对您问题的直接答案,但是,如果您只是想要 UINavigationController 功能,但不想在第一个屏幕上看到 UINavigationBar - 请查看:
Hiding the UINavigationBar only for the root UIViewController
关于iphone - 如何在 Iphone 上显示带有 UIButton 的 UINavigationController?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2488247/