如何在iPhone上显示带有UIButton的UINavigationController? [英] How to show a UINavigationController with an UIButton on the Iphone?

查看:58
本文介绍了如何在iPhone上显示带有UIButton的UINavigationController?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,第一个视图是带有几个uilabel和一个uibutton进行登录的UIView.登录后,我将向用户展示一个带有表的uinavigationcontroller,并带有按钮的动作.我知道如何从Xcode模板开始设置有效的导航控制器,但我不知道如何将其作为第二视图"加载

in my application the first view is an UIView with a couple of uilabel and an uibutton to do the login. I would to show an uinavigationcontroller with a table after the login, so with the action of the button. I know how to set up a working Navigation Controller starting with the Xcode Template but i dont know how to load this as a "Second View"

有帮助吗?

推荐答案

您可以将UINavigationController的视图添加到UIWindow,并使其遮盖第一个视图或从UIWindow中删除该视图.navigationController没有后退按钮可以将您带回到第一个视图(因为它的堆栈不包括第一个控制器),因此,如果您想提供返回的路径,则需要一个自定义按钮.

You can add the view of the UINavigationController to the UIWindow and either let it obscure the first view or remove that view from the UIWindow. The navigationController won't have a back button to take you back to the first view (since it's stack doesn't include the first controller), so you'll need a custom button if you want to provide a way back.

- (IBAction) buttonPressed {
    myNavigationController = [[UINavigationController alloc] initWithRootViewController:mySecondViewController];
    [self.view.window addSubview:myNavigationController.view];
    [self.view removeFromSuperview];
}

这是您问题的直接答案,但是,如果您只是想要UINavigationController功能,但又不想在第一个屏幕上看到UINavigationBar,请查看:

That's the direct answer to your question, however, if you simply want UINavigationController functionality but don't want to see the UINavigationBar on the first screen - check out:

为唯一的根UIViewController隐藏UINavigationBar

这篇关于如何在iPhone上显示带有UIButton的UINavigationController?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆