Add NavigationController to current view

旧城冷巷雨未停 提交于 2020-01-05 08:07:43

问题


I'm using a UIScrollView to display some images, and i need to present or push another view when the user selects one part of the image.This ScrollView is created only programmatically. How i can programmatically add a navigationController to it and present another view?

I tried this way but just give me the following error :

Pushing a navigation controller is not supported'

 StatesViewController * controller = [[StatesViewController alloc]initWithNibName:@"StatesViewController" bundle:nil];

    UINavigationController * Navcontroller = [[UINavigationController alloc] initWithRootViewController:controller];

    [self presentModalViewController: Navcontroller animated: YES];

回答1:


this might help you.

 NextViewController *nextViewController=[[NextViewController alloc]initWithNibName:@"NextViewController" bundle:nil];
    UINavigationController *navBar=[[UINavigationController alloc]initWithRootViewController:nextViewController];
    [self.navigationController presentModalViewController:navBar animated:YES];


来源:https://stackoverflow.com/questions/12412526/add-navigationcontroller-to-current-view

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