4
votes

I've run into a sort of roadblock with my iPad app. I apparently made some unrecoverable change to my code recently and now it will only launch with a black screen. It displays the LoadingImage for a split second and goes right to black.

In an effort to streamline what sort of problem I'm looking for, I'd like some advice on where should I start looking? I've done my best so far to check and recheck everything I can think of already, so I'm ready to start the search over with some guidance. More specifically, what are some of the most common reasons that your code will just result in a black screen, without running any code at all. Would it be an InterfaceBuilder issue, an Xcode .h issue, a .m issue with my methods or what? I've sort of accidentally solved the issue a few times in the past, but am struggling to find the source this time. I've added NSLog calls throughout my code to help narrow down the problem (in every .m file actually) and none of them print to the log at all.

Facts:

  • I'm using the latest Xcode and iOS SDK (for iPad, 3.2).
  • It does it in both the simulator and my actual iPad.
  • My iPad is not, and hasn't ever been Jailbroken.
  • My app is actually really simple, it's just a single split-view with a detail view and a custom root view which has a resized table in it.

Any help anyone can provide would really save me a lot of whining, mopeyness and crying. heh

Thanks.

Additional Requested Code:
viewDidLoad from MasterView.m

- (void)viewDidLoad {
    [super viewDidLoad];
    NSLog(@"Master: This self: %@", self);

    self.contentSizeForViewInPopover = CGSizeMake(320.0, 600.0);
    self.arrMenuOptions = [[NSArray arrayWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"MainMenuOptions" ofType:@"plist"]] retain];
}

viewDidLoad from DetailView.m

- (void)viewDidLoad {
    /// Initialize the preset things.
    NSLog(@"Detail: This self: %@", self);
    eleDetailToolbar.barStyle = UIBarStyleBlack;

    eleWebView.opaque = NO;
    eleWebView.backgroundColor = [UIColor clearColor];
    eleWebView.delegate = self;
    [super viewDidLoad];
}

AppDelegate excerpt

@implementation AssistantAppDelegate

@synthesize window, splitViewController;//, detailViewController, masterViewController;
//rootViewController, eleMasterNavigationItem

#pragma mark -
#pragma mark Application lifecycle

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    
    NSLog(@"AppDelegate: This self: %@", self);

    // Override point for customization after app launch    

    // Add the split view controller's view to the window and display.
    [window addSubview:splitViewController.view];
    [window makeKeyAndVisible];

    return YES;
}
2
Had the same issue on iPad 3 but the screen color was gray. The only thing I found - restart device for proper workfnc12

2 Answers

6
votes
  1. Are you getting any error messages on the Run console?
  2. Do you have a view hooked up in interface builder? Or trying to load a non-existent XIB file?
  3. Do you have the main nib file base name key populated in the info.plist file?
  4. What is in your applicationDidFinishLaunching and viewDidLoad methods?
  5. Have you deleted any references to something in Interface Builder?
  6. Have you added any new resources recently that could be corrupted?

Please update your question if possible with code

Update based on comments: How are you adding a window if you don't have an applicationDidFinishLaunching method?

You should have something like this in the App Delegate .m file:

@synthesize window;
@synthesize viewController;

- (void)applicationDidFinishLaunching:(UIApplication *)application {    

    // Override point for customization after app launch    
    [window addSubview:viewController.view];
    [window makeKeyAndVisible];

}

If this isn't here, no window gets added, and you get a black screen.

1
votes

I had the same problem. TechZen was right that it is because the main nib window is not loaded. So, the 3rd suggestion by iWasRobbed gave the best clue.

The problem was that, my app was made for both iPhone and iPad, so in the Info.plist, I had NSMainNibFile~iphone and NSMainNibFile~ipad, which are not recognised before iSO 3.2. What I needed to do is to add one more entry for compabilitiy purpose: NSMainNibFile.

Thanks for the clues, everyone! Happy coding!