UINavigationController作为UIViewController的子视图 [英] UINavigationController as child view of UIViewController

查看:67
本文介绍了UINavigationController作为UIViewController的子视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个不基于导航的应用程序.因此,App Delegate中没有UINavigationController.但是,我需要为一部分应用程序切换到UINavigationController.我目前采取的步骤...

I have an application that isn't nav based. So there is no UINavigationController in the App Delegate. However, I need to switch to a UINavigationController for a piece of the application. Steps I currently took...

  • 创建一个扩展UIViewController的新类
  • 通过IB添加了UINavigationController
  • 告诉IB,新的UIViewController的视图是UINavigationController的视图

现在的问题是文件的所有者需要它的视图集.但是无法通过IB进行指定.所以很明显,我并没有以正确的方式解决这个问题.朝着正确方向提出的任何建议都将受到赞赏.

The problem now is that the File's Owner needs it's view set. But via IB there is no way to specify this. So obviously, I'm not going about this the right way. Any tips in the right direction are much appreciated.

推荐答案

将IB中的导航控制器(在本例中为navController)连接到init并与您的控制器进行连接:

connect your navigation controller in IB (in this case navController) and init it with your controller:

MessageViewController *mView = [[MessageViewController alloc]initWithNibName:@"MessageView" bundle:nil];
mView.navController = [[UINavigationController alloc] initWithRootViewController:mView];
[self presentModalViewController:mView.navController animated:YES];
[mView release];

这篇关于UINavigationController作为UIViewController的子视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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