Xcode 5 Simulator Blank White Screen

2019-04-12 02:15发布

I just installed Xcode 5 (or the latest version) and created a new project. I created a storyboard, and added a label, but when I open my application in the iPhone simulator, I simply get a blank white screen with a status bar. What am I doing wrong?

I have OS X 10.9.1 Mavericks.

enter image description here

7条回答
Emotional °昔
2楼-- · 2019-04-12 02:57

I'm going to assume that you started an empty project, which doesn't start with a storyboard and then after creating the project, you created a storyboard file.

You have to tell your app which storyboard to load.

In the below screen shot, you'll want to click the "Main Interface" drop down and select the storyboard you want to start your app with.

enter image description here

This is the "Deployment Info" section of the "General" tab of your targets.


You also need to add a couple lines of code to your AppDelegate.m. It should look like this:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"YOUR_STORYBOARD_NAME" bundle:[NSBundle mainBundle]];
    UIViewController *vc =[storyboard instantiateInitialViewController];
    self.window.rootViewController = vc;
    [self.window makeKeyAndVisible];
    return YES;
}
查看更多
登录 后发表回答