0

i create one Main-iPad.Storyboard with Split View Controller Windows and App Delegate

here are my app Delegate.h

   IBOutlet UISplitViewController * rootcontroler;
   UIWindow *window;

here are my app Delegate.m

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    


    UIStoryboard * storyboard = [UIStoryboard storyboardWithName:@"Main-iPad" bundle:nil];
    UIViewController *initviewcontroller = [storyboard instantiateInitialViewController];
    [self.window setRootViewController:initviewcontroller];



}

and i added in Target-> General -> Main InterFace = Main-iPad

but when i run the app i received the black screen

user2296278
  • 528
  • 1
  • 4
  • 17
  • Select your `UISplitViewController` in your StoryBoard, in the Attribute inspector check if "Is Initial View Controller" is checked. – Pintouch Oct 24 '14 at 11:09
  • Do you have a details view linked to your `UISplitViewController`in your Storyboard? – Pintouch Oct 24 '14 at 11:31

1 Answers1

0

If you'd like to load storyboard with UISplitViewController initial vc from the code, remove respective key from target's Info.plist and add this code to the AppDelegate.m

// loading initial vc the way many folks around do
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];
UIViewController *vc =[storyboard instantiateInitialViewController];
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.rootViewController = vc;

// set up split vc
self.splitViewController = (UISplitViewController *)self.window.rootViewController;
UINavigationController *navigationController = [self.splitViewController.viewControllers lastObject];
navigationController.topViewController.navigationItem.leftBarButtonItem = self.splitViewController.displayModeButtonItem;
navigationController.topViewController.navigationItem.leftItemsSupplementBackButton = YES;
self.splitViewController.delegate = self;
self.splitViewController.preferredDisplayMode = UISplitViewControllerDisplayModeAllVisible;
self.splitViewController.preferredPrimaryColumnWidthFraction = 0.5;
// do any other split vc customization if needed

// this is an important part: call this _after_ split vc set up, otherwise you'd get wrong collapsed vc presented by split vc
[self.window makeKeyAndVisible];

also, the gist

Yevhen Dubinin
  • 4,657
  • 3
  • 34
  • 57