[self.navigationController pushViewController:ngView animated:YES]; not working

Nithinbemitk picture Nithinbemitk · May 23, 2013 · Viewed 12.1k times · Source

If i use

 NGViewController *ngView = [[NGViewController alloc]initWithNibName:Nil bundle:Nil];
[self presentViewController:ngView animated:NO completion:nil];

above code the controller will go to NGViewController page.

But if I use this navigation controller

NGViewController *ngView = [[NGViewController alloc]initWithNibName:Nil bundle:Nil];
[self.navigationController pushViewController:ngView animated:YES];

the Controller will be in same page.

Can any one tell that what's the problem.

Answer

user3332305 picture user3332305 · May 21, 2014

You should use this code

NGViewController *ngView = [[NGViewController alloc]initWithNibName:Nil bundle:Nil];
[self presentViewController:ngView animated:NO completion:nil];

after writting this line when then you you want go on different page with push view controller

UINavigationController *navigationController = [[UINavigationController       alloc]initWithRootViewController:ngView];

[self.navigationController pushViewController:navigationController animated:YES];

I hope you will solve this issue by this code Good luck