如果您的视图已经按预期工作,那么将导航控制器添加到模态视图非常简单。
NewViewController *newView = [[NewViewController alloc] initWithNibName:@"NewViewController" bundle:nil];
UINavigationController *navView = [[UINavigationController alloc] initWithrootViewController:newView];
[self presentModalViewController:navView animated:YES];
您的模态视图将继承导航栏和用于在该模态中呈现更多视图的所有属性。完成模式后,只需将其关闭。
在导航控制器上加载更多视图非常容易。
AnotherViewController *anotherView = [[AnotherViewController alloc] initWithNibName:@"AnotherViewController" bundle:nil];
[self.navigationController pushViewController:anotherView animated:YES];
要从堆栈中手动弹出视图控制器:
// note, you won't need to call this for the auto created back button, that is handled for you
// this would only be if you wanted manual control over going back outside the back button
[self.navigationController popViewControllerAnimated:YES];
一旦你完成了模态视图,你可以从任何地方调用它来让它消失,返回到你原来的视图。方便多个详细信息屏幕、注册过程等。
[self.navigationController dismissModalViewControllerAnimated:YES];