5

I have a storyboard View Controller, which is the first screen in my app. The rest of the app is designed with xib's. I want to segue from a button in the storyboard's VC to a XIB file. I know how to do this from a xib to storyboard, but how about this ?

Thanks in advance !

Sebyddd
  • 4,305
  • 2
  • 39
  • 43

1 Answers1

15

From xib to storyboard

UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle:nil];
UIViewController *initViewController = [storyBoard instantiateInitialViewController];

then

[self.window setRootViewController:initViewController];

or

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

From storyboard to xib

YourViewController *viewController=[[YourViewController alloc]initWithNibName:@"ViewControllerName" bundle:nil];

[self presentViewController:viewController animated:YES completion:nil];

In case of NavigatinController

[self.navigationController pushViewController:viewController animated:YES];
Sergey Kalinichenko
  • 714,442
  • 84
  • 1,110
  • 1,523
yasirmturk
  • 1,924
  • 2
  • 22
  • 32
  • When i try to go from storyboard to xib, i et this error: `FruitsMemoryGame[1588:60b] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key btnHighScores.'` – Sebyddd Aug 23 '13 at 12:02
  • 2
    Oh i forgot to import the classes. It's working now, thanks a lot :) – Sebyddd Aug 23 '13 at 12:08
  • that is due to a broken IBOutlet or IBAction – yasirmturk Aug 25 '13 at 11:24
  • I don't understand your porting going from xib to storyboard. So to have xib view `dog` segue to ViewController `forest`, I am not clear on how you know which view `initViewController` is pointing to. I am here guessing that you are coming from a viewController `house` that contains an instance of `dog`. – Katedral Pillon Jul 21 '14 at 23:42
  • in storyboard you set a starting point and that is what we get in `initViewController ` by using `[storyBoard instantiateInitialViewController]` – yasirmturk Jul 22 '14 at 09:29
  • What if the .xib's class is a UIView subclass and not a UIViewController subclass ? – Jack Berstrem Feb 19 '16 at 16:17