Bus*_*hid 2 iphone uiview uinavigationcontroller ios4
我在视图中有一个大小为320x218的UIView(下面的代码中的menuView).我想在此视图中加载导航控制器.我使用以下代码来做到这一点:
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];
Run Code Online (Sandbox Code Playgroud)
执行时,根视图不会显示在该视图中.仅显示导航栏,其余视图为空.
编辑:
我刚刚在MenuViewController的initWithNibName:和viewDidLoad中放置了一个NSLog().initWithNibName:中的那个被调用但viewDidLoad中的那个:不是:S
更新:
我试图推动menuController我的navigationController想法,因为它没有出现,它可能不在堆栈上.例外:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Pushing the same view controller instance more than once is not supported
Run Code Online (Sandbox Code Playgroud)
小智 8
call layoutsubviews可以正常工作.
[super loadView];
[self.view addSubview:navigationController.view];
[navigationController.view layoutSubviews];
Run Code Online (Sandbox Code Playgroud)