Question

I have just made my app universal by combining separate iPhone and iPad projects. Everything seems to be working but there is one major bug.

When the iPad app launches it just displays a black screen (presumably the window) and status bar. When I press the home button I suddenly see the SplitViewController as it disappears. When I open the app up again the SplitViewController is displayed.

I can't figure out why the controller only displays after I close and reopen the app. Any ideas?

(I don't have any idea what is causing this so if you need code samples from specific places let me know).

Thanks.

Edit:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    [Appirater appLaunched:YES];
    // Registers this class as the delegate of the audio session.
    [[AVAudioSession sharedInstance] setDelegate: self];    
    // Allow the app sound to continue to play when the screen is locked.
    [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];


justOpened = YES;
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.

if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
      {deleted}
} else {
    [self.window addSubview:self.splitViewController.view];
    [self.window makeKeyAndVisible];

    CGRect rect = CGRectMake(-2, self.window.frame.size.height-29, self.window.frame.size.width+2, 29);
    imgBar = [[UIImageView alloc] initWithFrame:rect];
    imgBar.contentMode = UIViewContentModeScaleToFill;
    imgBar.image = [UIImage imageNamed:@"wood_btm.png"];
    imgBar.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleTopMargin;

    self.splitViewController.showsMasterInPortrait = YES;
    self.splitViewController.title = @"Exams";
    self.splitViewController.splitPosition=280;
}

return YES;
}

Update:

By messing around with the window's background color I discovered that for some reason it was at the top of the view hierarchy. I then made the window's background color clear and I could see the SplitViewController. Strangely I can also interact with it. So essentially I have solved the problem by making the window clear. This is obviously not the ideal solution though so if anyone can think of a cause let me know.

Was it helpful?

Solution 2

By messing around with the window's background color I discovered that for some reason it was at the top of the view hierarchy. I then made the window's background color clear and I could see the SplitViewController. Strangely I can also interact with it. So essentially I have solved the problem by making the window clear.

OTHER TIPS

[self.window addSubview:self.splitViewController.view];
[self.window makeKeyAndVisible];
return YES;

should be at the end of -applicationDidFinishLaunching:WithOptions: method.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top