带导航控制器的模态视图

时间:2010-08-13 17:19:51

标签: ios iphone uinavigationcontroller

仍然无法弄清楚我做错了什么。只是尝试使用导航控制器获取模态视图。

这是我的项目 http://www.matthewpateman.com/New.zip

有谁能告诉我我做错了什么?我希望“ShopModalView.xib”能够在导航控制器中弹出,但它只是在空白页面上显示...

3 个答案:

答案 0 :(得分:45)

将其显示为模态视图并将控制器包装在导航控制器中以提供导​​航栏,以防您想要添加编辑,保存等按钮

ModalViewController *modalController = [[ModalViewController alloc] initWithNibName:@"ModalViewController" bundle:nil];
modalController.delegate = self; // Set any delegate you may have

// This is where you wrap the view up nicely in a navigation controller
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:modalController];

// You can even set the style of stuff before you show it
navigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;

// And now you want to present the view in a modal fashion
[self presentModalViewController:navigationController animated:YES completion:nil];

答案 1 :(得分:3)

ShopModalViewController *shopMVC = [[ShopModalViewController alloc] initWithNibName:@"ShopModalViewController" bundle:nil];
//set properties
UINavigationContrller *navCon = [[UINavigationController alloc] initWithRootViewController:shopMVC];
[self presentModalViewController:navCon animated:YES];
[shopMVC release];
[navCon release];

答案 2 :(得分:2)

对于那些想在Swift 3.x中执行此操作的人:

echo nl2br(stream_get_contents($stream_out));