0

I'm implementing FPPopover into my application, it was working alright until I added some code to the app delegate to manage and display the correct storyboard depending on the device throughout the app. The code I added is as follows...

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
UIStoryboard *storyboard = [self getStoryboard];
UIViewController *initViewController = [storyboard instantiateViewControllerWithIdentifier:@"Init"];
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.rootViewController = initViewController;
[self.window makeKeyAndVisible];
sleep(3);

return YES;}

-(UIStoryboard*) getStoryboard {
UIStoryboard *storyBoard = nil;
if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) {
    storyBoard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPad" bundle:nil];
}else{
    if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone){
        // The iOS device = iPhone or iPod Touch
        CGSize iOSDeviceScreenSize = [[UIScreen mainScreen] bounds].size;
        if (iOSDeviceScreenSize.height == 480){
            // iPhone 3/4x
            storyBoard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];

        }else if (iOSDeviceScreenSize.height == 568){
            // iPhone 5 etc
            storyBoard = [UIStoryboard storyboardWithName:@"Storyboard_iPhone_5" bundle:nil];
        }
    }
}

return storyBoard;}

If I delete all this code from my App delegate the popover works perfectly... But if I add it it doesn't work... I have no idea what is going on. Can anyone help?

JOM
  • 8,139
  • 6
  • 78
  • 111
  • Possibly, your storyboard/initViewController is being initialized to `nil`. Try adding a `NSLog(@"%@",storyboard);` and `NSLog(@"%@",initViewController);` after the respective lines of intializtion – Ayan Sengupta Nov 15 '13 at 22:44

1 Answers1

0

You don't need of this code..go in the project's general tab and set your storyboard for iPhone and iPad here:

enter image description like here

In the storyboard you can select the inital view controller..

So you can delete all your code for storyboard and initial viewController

This is the code that i use in my appDelegate :) :

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    return YES;
}
Matteo Gobbi
  • 17,697
  • 3
  • 27
  • 41