1

Hi there I used this code to move in to new contorller just with code and without segue .

    UIStoryboard * mainstoryb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController * vc = [mainstoryb instantiateViewControllerWithIdentifier:@"online_shop"];
[self presentViewController:vc animated:YES completion:nil];

how do I show Navigation bar or title bar on next view ?

jscs
  • 63,694
  • 13
  • 151
  • 195
kiamoz
  • 714
  • 1
  • 7
  • 18

4 Answers4

5

You need to present NavigationController as below :

 UIViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:ContactUSVCID];
 UINavigationController *objNav = [[UINavigationController alloc] initWithRootViewController:vc];
[self presentViewController:objNav animated:YES completion:nil];
KKRocks
  • 8,222
  • 1
  • 18
  • 84
2

if you want navigation bar, then you have to push not present

  UIStoryboard *storyboard = [UIStoryboard storyboardWithName:storyboardName bundle: nil];


      SecondViewController * vc = [storyboard instantiateViewControllerWithIdentifier:@"ViewControllerB"];
    /********if dont have navigation bar***********/
 UINavigationController *initialNavigationController = (UINavigationController*)[self.storyboard instantiateViewControllerWithIdentifier:@"HomeNavCtrl_id"];
[self presentViewController:initialNavigationController animated:YES completion:nil];

/**********else*************/

    [[self navigationController] pushViewController:vc animated:YES];
Ajjjjjjjj
  • 669
  • 4
  • 12
1

Embed your ViewController in navigation controller and storyboard id to navigation controller then use this code

  UINavigationController *initialNavigationController = (UINavigationController*)[self.storyboard instantiateViewControllerWithIdentifier:@"HomeNavCtrl_id"];
[self presentViewController:initialNavigationController animated:YES completion:nil];
Vinay Kumar
  • 107
  • 1
  • 12
1

If you present a view controller it will always be presented full screen. Try this

UIStoryboard * mainstoryb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController * vc = [mainstoryb instantiateViewControllerWithIdentifier:@"online_shop"];
[self presentViewController:navigationController animated:YES completion:nil];
RajeshKumar R
  • 15,445
  • 2
  • 38
  • 70