ios: Pushing another ViewController on a model view

独自空忆成欢 提交于 2019-12-23 22:34:36

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!