Joel Derfner
Joel Derfner

Reputation: 2207

app works fine on iPhone; iPad simulator gives only black screen

Here's my applicationDidLaunch method from the app delegate:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[self.window makeKeyAndVisible];

                //This hides the status bar throughout the app.

[UIApplication sharedApplication].statusBarHidden=YES;


NSMutableArray *tabItems = [[NSMutableArray alloc] initWithCapacity:5];

GHHaikuViewController *hvc = [[GHHaikuViewController alloc] init];
hvc.tabBarItem.title = @"Home";
hvc.tabBarItem.image = [UIImage imageNamed:@"53-house.png"];
[tabItems addObject:hvc];

GHComposeViewController *cvc = [[GHComposeViewController alloc] init];
cvc.tabBarItem.title = @"Compose";
cvc.tabBarItem.image = [UIImage imageNamed:@"216-compose.png"];
[tabItems addObject:cvc];

GHWebViewController *wvc = [[GHWebViewController alloc] init];
wvc.tabBarItem.title = @"Buy";
wvc.tabBarItem.image = [UIImage imageNamed:@"80-shopping-cart.png"];
[tabItems addObject:wvc];

GHFeedback *fvc = [[GHFeedback alloc] init];
fvc.tabBarItem.title = @"Feedback";
fvc.tabBarItem.image = [UIImage imageNamed:@"18-envelope.png"];
[tabItems addObject:fvc];

GHSettingsViewController *svc = [[GHSettingsViewController alloc] init];
svc.tabBarItem.title = @"Settings";
svc.tabBarItem.image = [UIImage imageNamed:@"20-gear-2.png"];
[tabItems addObject:svc];

UITabBarController *tbc = [[UITabBarController alloc] init];
tbc.viewControllers = tabItems;
self.window.rootViewController = tbc;

return YES;
}

And here's viewDidLoad from the first view controller, simplified for clarity:

-(void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor whiteColor];
background.backgroundColor = [UIColor whiteColor];
[self.view addSubview:background];
NSLog(@"View loaded.");
}

Everything works fine on iPhone. On iPad (or at least simulator), "View loaded" logs, but instead of a white screen it's just black. Earlier I was playing around with a storyboard for the iPad, but I've deleted it and I THINK I removed all the files, and now everything is running from code. I've cleaned the project. What am I overlooking?

EDIT: Here's a shot of the target summary in Xcode.

enter image description here

Upvotes: 0

Views: 534

Answers (2)

Felix
Felix

Reputation: 35384

If you don't use a main storyboard or xib you need to create the UIWindow in code:

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

Upvotes: 2

SAE
SAE

Reputation: 1739

Make sure, that the storyboard for iPad is cleared in the project settings. IMO Xcode doesn't delete the entry when deleting a storyboard. You should only have storyboard for iPhone configured there.

Upvotes: 1

Related Questions