xcode 模拟器中的空白屏幕问题

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6131365/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 21:07:12  来源:igfitidea点击:

Blank Screen Issue in Simulator

xcodeiosipadinterface-builder

提问by RaysonK

I'm working on a game for the iPad, and I have it start up with a menu screen. For a while, the menu screen would come up just fine in the simulator. I'm using the main view controller that xcode provides when starting up a view-based application. But, unfortunately, I accidentally cut off the connection between the UIView and the view controller in interface builder, and after reconnecting it, the screen comes up as blank now. It works fine when I simulate the screen in interface builder, but not when running in xcode. Here's the code for the view controller:

我正在为 iPad 开发一款游戏,我让它以菜单屏幕启动。有一段时间,菜单屏幕会在模拟器中正常显示。我正在使用 xcode 在启动基于视图的应用程序时提供的主视图控制器。但是,不幸的是,我不小心在界面构建器中切断了 UIView 和视图控制器之间的连接,重新连接后,屏幕现在显示为空白。当我在界面构建器中模拟屏幕时,它工作正常,但在 xcode 中运行时则不然。这是视图控制器的代码:

//
//  FunctionMachineViewController.h
//  FunctionMachine
//
//  Created by Kameron Schadt on 5/24/11.
//  Copyright 2011 Willamette University. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface FunctionMachineViewController : UIViewController {

IBOutlet UITextField* equation;
IBOutlet UISlider* startLevel;
IBOutlet UITextView* startLevelNumber;

}

- (IBAction) startOnePlayer:(id)sender;
- (IBAction) startTwoPlayer:(id)sender startingEquation:(NSString*)equationUsed;
- (IBAction) sliderValueChanged:(UISlider*)sender;

@property(nonatomic, retain) IBOutlet UISlider* startLevel;
@property(nonatomic, retain) IBOutlet UITextField* equation;
@property(nonatomic, retain) IBOutlet UITextView* startLevelNumber;

@end


//
//  FunctionMachineViewController.m
//  FunctionMachine
//
//  Created by Kameron Schadt on 5/24/11.
//  Copyright 2011 Willamette University. All rights reserved.
//

#import "FunctionMachineViewController.h"
#import "GameViewController.h"

@implementation FunctionMachineViewController

@synthesize equation, startLevel, startLevelNumber;

- (IBAction)sliderValueChanged:(UISlider*)sender {
[startLevelNumber setText:[NSString stringWithFormat:@" %.1f", [sender value]]];
}

-(IBAction)startOnePlayer:(id)sender
{
GameViewController* GameView = [[GameViewController alloc] initWithNibName:nil bundle:nil];
[GameView isOnePlayer:YES];
[self presentModalViewController:GameView animated:YES];
}

-(IBAction)startTwoPlayer:(id)sender startingEquation:(NSString*)equationUsed
{
GameViewController* GameView = [[GameViewController alloc] initWithNibName:nil bundle:nil];
[GameView isOnePlayer:NO];
[self presentModalViewController:GameView animated:YES];
}

- (void)viewDidLoad {
[super viewDidLoad];
}


// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:    (UIInterfaceOrientation)interfaceOrientation {
return YES;
}

- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];

// Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}


- (void)dealloc {
[super dealloc];
}

@end

I didn't really see any problem here, so I'm assuming it has something to do with me reconnecting the view controller to the view. I don't have an actual view file that I'm using, just the viewcontroller. Can anybody help?

我在这里没有真正看到任何问题,所以我假设这与我将视图控制器重新连接到视图有关。我没有正在使用的实际视图文件,只有视图控制器。有人可以帮忙吗?

采纳答案by Scott Forbes

Check the setting of "Main nib file base name" in [YourApp]-info.plist, in the "Supporting Files" folder – if you've changed the name of your root view controller, you may need to change the name here as well.

检查 [YourApp]-info.plist 中“Supporting Files”文件夹中“Main nib file base name”的设置——如果您更改了根视图控制器的名称,则可能需要将此处的名称更改为好。

回答by Geodude

For some odd reason my Referencing outlet for the App Delegate was disconnected.

由于某种奇怪的原因,我的 App Delegate 的引用插座断开了。

Try creating a referencing outlet from delegate to File's Owner using the connections inspector (farthest right menu) for your App Delegate.

尝试使用应用程序委托的连接检查器(最右侧的菜单)创建从委托到文件所有者的引用出口。