4

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.

Code cracker
  • 3,105
  • 6
  • 37
  • 67
Nithinbemitk
  • 2,710
  • 4
  • 24
  • 27

7 Answers7

2

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

Vaandu
  • 4,857
  • 12
  • 49
  • 75
1

Your self.navigationController is probably nil - check it out through debugging. Your self view controller is not within a UINavigationController.

graver
  • 15,183
  • 4
  • 46
  • 62
1

Now i m using this code

 NGViewController *ngView = [[NGViewController alloc]initWithNibName:Nil bundle:Nil];
 [UIView beginAnimations:nil context:NULL];
 [UIView setAnimationDuration: 0.50];
 [self presentViewController:ngView animated:NO completion:nil];

so that it wil give same effect other

Nithinbemitk
  • 2,710
  • 4
  • 24
  • 27
  • 1
    I hope you are ending the animations later...(P.S. this way of animating is really old [pre iOS 4]) – borrrden May 23 '13 at 10:18
1

Self Controller should have navigation controller (in Storyboard) in order to navigate.

[self.navigationController pushViewController:nextController animated:YES];
FARAZ
  • 645
  • 7
  • 6
0

UINavigationController is a controller of controllers and it is designed to allow you to push and pop controllers and manage a hierarchy of your view's. And your navigationController property tells you whether your NGViewController is currently in a UINavigationController's hierarchy; if not (as in this case), the navigationController property returns nil.

Buntylm
  • 7,345
  • 1
  • 31
  • 51
0

You have to create your own navigation controller and then try to push the view controllers and thus build up a view hierarchy. I normally would suggest this:

 UINavigationController *navigationController = [[UINavigationController       alloc]initWithRootViewController:firstviewController];
[self.window setRootViewController:navigationController];
navigationController.delegate = self;
navigationController.navigationBarHidden = YES;
GhostCode
  • 452
  • 6
  • 17
-2

you need to declare this in your first controller

NGViewController *ngView = [[NGViewController alloc]init];
[self.navigationController pushViewController:ngView animated:YES];