darkman
darkman

Reputation: 1003

Add NavigationController to current view

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];

Upvotes: 1

Views: 2988

Answers (1)

prashant
prashant

Reputation: 1920

this might help you.

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

Upvotes: 2

Related Questions