从UIView加载UINavigation控制器 [英] loading a UINavigation controller from a UIView

查看:97
本文介绍了从UIView加载UINavigation控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在设计一个具有登录屏幕的应用程序。它是一个带有用户名/密码和提交按钮的UIView。一旦用户成功通过身份验证,我想加载一个包含导航控制器和导航栏的新xib文件。在条形图下面我想加载一个tableView并在其他视图之间切换,因为我随着它的编程移动。

i am designing an app that has a login screen. it is a UIView with username/password and a button to submit. once the user authenticated successfully, i want to load a new xib file that holds a navigation controller and a navigation bar. below the bar i want to load a tableView and switch between other views as i move along with the programming of it.

我所做的是创建一个继承自的新类UINavigationController并组装了xib文件以包含导航控制器。我把它连接到文件的所有者,我正在模拟这样加载导航控制器:

what i did is create a new class that inherits from UINavigationController and assembled the xib file to include the navigation controller. i hooked it back up to file's owner and i'm loading the navigation controller modally like this:

 myNavController* navVC = [[myNavController alloc] initWithNibName:@"navXibFile" bundle:nil];

    [self presentModalViewController:navVC animated:YES];
    [navVC release];

当导航控制器显示时,此功能正常。然而,它显示没有标题,即使我在IB中设置了一个。而且,tableView的代表通过IB连接,但我甚至看不到空行。所有我看到的是顶部的空导航栏和它下方的空白视图(一片)。

this works okay as the navigation controller shows up. however, it shows up with no title, even though i've set one up in IB. moreover, the tableView's delegates are hooked up via IB but i cannot even see empty lines. all i see is an empty navigation bar at the top and blank view (one piece) below it.

感谢您的帮助。

推荐答案

所以我想出来......首先,这是一个设计决定权吗?是由导航控制器管理的应用程序?如果是这样(这是我的情况),期望主(第一)视图,即登录页面,您需要做的就是在ViewdidLoad中隐藏主视图的导航栏:

so i figured it out... first it's a design decision right? is the app being managed by a navigation controller? if so (which is my case), expect the main (first) view, that is a login page, all you need to do is to hide the navigation bar in your ViewdidLoad for the main view:

[self.navigationController setNavigationBarHidden:YES animated:YES];

一旦用户登录并按下这样的下一个视图:

once the user logs in and you push the next view like this:

MainTableViewController* mainTableVC = [[MainTableViewController alloc] 
                                        initWithNibName:@"MainTableViewController" bundle:nil];

[self.navigationController pushViewController:mainTableVC animated:YES];
[mainTableVC release];

最后,在下一个视图控制器的ViewDidLoad中:

and lastly, in the ViewDidLoad of the next view controller:

[self.navigationController setNavigationBarHidden:NO animated:YES];

如果您的应用需要应用的特定部分的导航控制器,但不是全部,如果它,你将需要使用VC来管理这个,就像appDelegate管理基于样本导航的示例应用程序一样。

in case your app needs a navigation controller for a specific section of the app but not all if it, you will need to use the VC to manage this, in a similar way the appDelegate manages the sample navigation based sample app.

我希望这可以帮助任何努力包袱的人围绕这里实施的设计模式。

i hope this helps anyone struggling with wrapping their minds around the design patterns implemented here.

欢呼。

这篇关于从UIView加载UINavigation控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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