Xcode 5 Simulator Blank White Screen

懵懂的女人 提交于 2020-01-23 01:32:11

问题


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.


回答1:


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;



回答2:


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



回答3:


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.




回答4:


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".




回答5:


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




回答6:


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




回答7:


Click "Main.storyboard" -> on right prat "Interface Builder Document" uncheck "Use Auto Layout, "Use Size Classes" & "Use as Lunch Screen"



来源:https://stackoverflow.com/questions/21973886/xcode-5-simulator-blank-white-screen

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!