views:

351

answers:

2

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  A: 
  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.

iWasRobbed
more questions:Have you added the view you want to display to the window?Have you made the window visible?The applicationDidFinishLaunchingWithOptions method is implemented?
Jesse Naugher
+1 The problem is almost certainly that you do not load the window in `applicationDidFinishLaunching:` That produces a blank black window with no other apparent problem because the app thinks that is what you want. A blank white window means you didn't load a view into the window.
TechZen
Thanks for responding IWasRobbed, and my apologies for my long response delay. Here's the best I know right now:#1. No error messages, no console posts, no warnings, no build errors, nothing of any sort, even when I add code to dump to the console, it just never gets executed.#2. Yes I have all my views linked in Interface Builder. The primary one (MainWindow.xib), the root view (MasterView.xib) and the detail view (DetailView.xib)#3. Yes.#4.1 viewDidLoad is below. I don't have an applicationDidFinishLaunching, and I don't believe it ever did. :(// Continued in next comment.
Brak
#4.2 - (void)viewDidLoad { [super viewDidLoad]; NSLog(@"Detail: This self: %@", self); self.contentSizeForViewInPopover = CGSizeMake(320.0, 600.0); self.arrMenuOptions = [[NSArray arrayWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"MainMenuOptions" ofType:@"plist"]] retain];}#5. I may have, but I can't know for certain. Is there an easy way to "profile" the code and determine everything that it's requesting that I may be missing in my nibs/xibs?#6. I've not added any new resources, and everything seems uncorrupted. Sorry about the formatting. No newlines really bites.
Brak
See updated post. You need an `applicationDidFinishLaunching` method.....
iWasRobbed
Sorry I didn't look hard enough at my code. I do have an <code>applicationDidFinishLaunching</code> method. Original question updated.
Brak
A: 

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!

William