0

Iam doing one project using storyboard ,in one viewcontroller i have a button.When i clicked that it will move to next viewcontroller but its a separate xib file. Now i tried to add aback button to that xib file So i can move back to my storyboard but its not working form me ?

I tried following code for moving from xib to storyboard viewcontroller

viewcontrollerOne *list= [self.storyboard instantiateViewControllerWithIdentifier:@"detail"];
[self presentModalViewController:list animated:YES];

please let me know the reason why its not working?

Naveen
  • 1,251
  • 9
  • 20
  • 38
  • if you want to add it as programmetically then http://stackoverflow.com/questions/14704686/how-to-add-bar-buttons-in-a-uitoolbar/14704726#14704726 – iPatel Apr 06 '13 at 06:02
  • Please Read My question. – Naveen Apr 06 '13 at 06:04
  • @Naveen, Please check have you given identifier name in storyboard for that class correctly, if yes please also try this method instead of presentModalViewController, since it is deprecated: [self presentViewController:list animated:YES completion:nil]; – Ramu Pasupuleti Apr 06 '13 at 06:32
  • @RamuPasupuleti : its not working i gor this error Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to present a nil modal view controller on target .' – Naveen Apr 06 '13 at 06:39
  • @Naveen, This error occur while you are trying to present a view controller that has not instantiated. Please check class names and identifier names. – Ramu Pasupuleti Apr 06 '13 at 06:42
  • @Naveen, viewcontrollerOne is a part of stoardboard or not. If not,it is a separate xib file..above code couldn't work..choose this.. viewcontrollerOne *list = [[viewcontrollerOne alloc] initWithNibName:@"viewcontrollerOne" bundle:nil]; list.modalTransitionStyle = UIModalTransitionStyleCoverVertical; [self presentModalViewController:list animated:YES]; Try this, and let me know – Ramu Pasupuleti Apr 06 '13 at 06:48
  • @RamuPasupuleti ViewcontrollerOne is a part of story board but viewControllerTwp is a separate xib – Naveen Apr 06 '13 at 06:49
  • @Naveen, http://stackoverflow.com/questions/8705815/iphone-ios5-storyboard-how-to-load-a-uiviewcontroller-with-a-custom-xib-file – Ramu Pasupuleti Apr 06 '13 at 06:54

2 Answers2

2

you can try changing your project to UINavigationController and then in the storyboard you can link the views

Daljeet Seera
  • 161
  • 1
  • 8
0

This code will work when you want to move from an xib to a viewcontroller in Storyboard,Its working for me.

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"IDENTIFIER"];
[self.navigationController pushViewController:vc animated:YES];
Naveen
  • 1,251
  • 9
  • 20
  • 38