简体   繁体   中英

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.

在此处输入图片说明

如果您不使用主故事板或xib,则需要在代码中创建UIWindow

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM