模态视图与导航控制器

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

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

有谁可以告诉我我做错了什么? 我想要“ShopModalView.xib”在导航控制器中popup,但它只是一个空白页面…

将其作为模式视图呈现,并将控制器包裹在导航控制器中,以便在需要添加编辑,保存等button时提供导航栏

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]; 

对于那些想在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)