Modal View with Navigation Controller

2019-01-22 00:09发布

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

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…

3条回答
叼着烟拽天下
2楼-- · 2019-01-22 00:33

For those wanting to do this in 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)
查看更多
闹够了就滚
3楼-- · 2019-01-22 00:34

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];
查看更多
地球回转人心会变
4楼-- · 2019-01-22 00:52
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];
查看更多
登录 后发表回答