问题
I have a viewcontroller that is presented modally.
[self presentModalViewController:ViewControllerA animated:YES];
Within this ViewControllerA I've got a table view and when the user clicks on a cell another ViewControllerB should be pushed on top of the current one.
- (void)tableView:(UITableView *)tv didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[self.navigationController pushViewController:ViewControllerB animated:YES];
The problem: I cannot push anything because it is push from a modally presented viewconrtroller. Is there some way to solve my problem?
回答1:
You can push ViewControllerB as another modal view.
But if you want to use the navigational controller, here is a section from Apple's doc:
You can present UINavigationController objects modally in the same way that you would present a custom view controller. (In rare cases, you could even present a tab bar controller.)
When presenting a navigation controller modally, you always present the UINavigationController object itself, rather than presenting any of the view controllers on its navigation stack. However, individual view controllers on the navigation stack may themselves present other view controllers modally, including other navigation controllers.
来源:https://stackoverflow.com/questions/8619805/ios-pushing-another-viewcontroller-on-a-model-view