-1

I need to choose UIViewController after Spash Screen executed. For example: After Splash Screen executed

if (condition) {
   call UIViewController2
}else{
   call UIViewController2
}

I found a correct information here Programmatically set the initial view controller using Storyboards and worked. Thanks for all

Community
  • 1
  • 1
  • Do it in **Appdelegate.m**'s `applicationDidFinishLaunchingWithOptions:` method. It will call when your app has been launched. – TheTiger Aug 07 '13 at 18:45
  • `[self.navigationController pushViewController:viewController animated:YES];` where `self.navigationController` is a `UINavigationController` and viewController is your `UIViewController`. – JeffRegan Aug 07 '13 at 18:46
  • I am using StoryBoard and show this message error : "Failed to instantiate the default view controller for UIMainStoryboardFile 'MainStoryboard' - perhaps the designated entry point is not set" – user2661939 Aug 07 '13 at 18:59

2 Answers2

0

Hope this helps

BOOL condition;

if(condition) {
   UIViewController2 *v2 = [[UIViewController2 alloc] init];

   [self presentingViewController:v2 completion:nil];  // iOS 6.0 +
   [self presentModalViewController:v2 animated:YES];  // iOS 2.0, but depreciated in iOS 6
}
else {
   // not fully sure what you're asking for this part, but do the same as above
   // if you're looking for the same view controller
}
user2277872
  • 2,963
  • 1
  • 21
  • 22
  • `presentModalViewController:` it should not be as IOS 3.0+ as IOS 6.0 is also greater than 3.0. It should be less than 6 – TheTiger Aug 07 '13 at 18:50
  • I am using StoryBoard and show this message error : "Failed to instantiate the default view controller for UIMainStoryboardFile 'MainStoryboard' - perhaps the designated entry point is not set" – user2661939 Aug 07 '13 at 18:58
  • i was trying to give different ways of showing the view controller. they didn't say the iOS they are using – user2277872 Aug 07 '13 at 19:00
0

this may help you:

import in your viewController.h the ViewController target and give in storyboard an identifier:

  if(condition) {

   viewController1 *v1 = (viewController1 *)[self.storyboard instantiateViewControllerWithIdentifier:@"view1"];
   [self presentViewController:v1 animated:YES completion:nil];
  }

 else {

 // same code but with other viewController
 }
Ilario
  • 5,979
  • 2
  • 32
  • 46