简体   繁体   中英

ios: Pushing another ViewController on a model view

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM