[英]Modal View with Navigation Controller
still cannot figure out what I am doing wrong. 仍然无法弄清楚我做错了什么。 Just trying to get a modal view with a navigation controller inside. 只是试图用里面的导航控制器获得模态视图。
Here is my project http://www.matthewpateman.com/New.zip 这是我的项目http://www.matthewpateman.com/New.zip
Can anybody tell me what I am doing wrong? 谁能告诉我我做错了什么? I want "ShopModalView.xib" to pop up in the navigation controller, but its just diplaying a blank page… 我希望“ShopModalView.xib”能够在导航控制器中弹出,但它只是在空白页面上进行了...
Present it as a modal view and wrap the controller in a navigation controller to provide a navigation bar in case you want to add edit, save, etc buttons 将其显示为模态视图并将控制器包装在导航控制器中以提供导航栏,以防您想要添加编辑,保存等按钮
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];
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];
For those wanting to do this in Swift 3.x: 对于那些想在Swift 3.x中执行此操作的人:
// Obtain your viewcontroller
let viewController = ...
// Initialize a navigation controller, with your view controller as its root
let navigationController = UINavigationController(rootViewController: viewController)
navigationController.navigationBar.barStyle = .blackTranslucent
// Present it modally from the current controller
present(navigationController, animated: true, completion: nil)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.