且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

带有导航控制器的模态视图

更新时间:2023-02-16 09:09:27

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

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