iphone - UINavigationController 不显示 Root View Controller

标签 iphone uiview ios4 uinavigationcontroller

我在 View 中有一个大小为 320x218 的 UIView(下面代码中的 menuView)。我想将导航 Controller 加载到该 View 中。我使用以下代码来执行此操作:

MenuViewController *menuController = [[MenuViewController alloc] initWithNibName:@"MenuViewController" bundle:nil];

UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:menuController];
navigationController.navigationBarHidden = YES;

[menuView addSubview:navigationController.view];
[menuController release];
[navigationController release];

当我执行它时, Root View 不会显示在该 View 中。仅显示导航栏, View 的其余部分为空。

编辑:

我刚刚在 MenuViewController 的 initWithNibName: 和 viewDidLoad: 中放置了一个 NSLog() 。 initWithNibName: 中的那个被调用,但 viewDidLoad: 中的那个没有被调用:S

更新:

我尝试将 menuController 推送到我的 navigationController ,因为它没有出现,它可能不在堆栈上。异常(exception):

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Pushing the same view controller instance more than once is not supported

最佳答案

调用layoutsubviews确实有效。

[super loadView];
[self.view addSubview:navigationController.view];
[navigationController.view layoutSubviews];

关于iphone - UINavigationController 不显示 Root View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6909660/

相关文章:

iphone - ios 查找所有保存的文件

iPhone/iPad 前置摄像头 FOV

ios - uitableview重置删除按钮

ios - AVFoundation 和 UITableView

iphone - 在 Facebook 墙上添加照片

iphone - ASIHTTPRequestErrorDomain Code=4 "请求被取消

iphone - #error 1107 在 iPhone 上运行 flash 游戏时,使用 Adob​​e Air

ios - 如何在按钮状态更改时更改用户定义的运行时属性

ios - Swift:子类化 UIViewController 的 Root View

objective-c - 在 NSMutableArray 中存储 float 会产生意想不到的结果