简体   繁体   中英

Xcode 5 Simulator Blank White Screen

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.

在此输入图像描述

I know I'm quite late to this, but the solution to this problem is quite simple and is even shown in one of Apple's own tutorials .

Assuming that you started off with an "Empty Project", created a storyboard from scratch, and set your storyboard as the main interface, you need to remove a few lines in the first method of AppDelegate.m.

This:

    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];
    return YES;

Should become just this:

    return YES;

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.

在此输入图像描述

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;
}

Your project does not have a view controller. When you created your project, you should have started with a "Single view project", which would have created a view controller for you. In that case, you would have been able to see your label.

EDIT TO FIX:

If you would like to fix this, remove the property "Main nib file base name." This can be found in the "info" tab of your target.

在此输入图像描述

The problem:

It seems that when you created your application, you selected the "Empty Application" template. Then you added the Storyboard from the user interface section. When you added the label and ran the application, you can't see the "Hello, World" label, because the application does not have a root view controller at the end of the application launch.

Try to create a "Single View Application".

Just wanted to chime in on this thread and shed some light on the matter. I myself was working on my first project and was getting the white screen. I found this article and it helped and it didn't, but this is what worked for me. Everyone is right on what they posted, but I was running 9.2 simulator when in fact I only have 9.1 installed (if you need help with this go to Xcode> Preferences>Downloads and download the appropriate package. Once I did that I ran the simulator and got the white screen. Now my white screen had the carrier and batt icon at the top. To fix this issue in Simulator: Hardware>Device>9.1 and a reboot occurred and then it works...

Hope this helped.

SithAdmin

I had the same issue (blank screen) for a stupid simple error. Actually, the elements appeared and soon fade away. My mistake was that I was not creating in in Main .storyboard (but LaunchScreen .storyboard in place, so that it obviously disappeared couple of seconds after start). Stupid but at least, quick to check: create views in Main, not LaunchScreen...

单击右侧的“ Main.storyboard ” - >“ Interface Builder Document ”取消选中“ Use Auto Layout” ,“ Use Size Classes ”和“ Use as Lunch Screen

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