xcode - 模拟器中的黑屏问题

标签 xcode ios ipad interface-builder

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

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

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

最佳答案

检查“Supporting Files”文件夹中 [YourApp]-info.plist 中“Main nib file base name”的设置——如果您更改了 Root View Controller 的名称,则可能需要更改名称也在这里。

关于xcode - 模拟器中的黑屏问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6131365/

相关文章:

iphone - 将前面带有标签的 NSString 中的单词分开

ios - UITextfield 不能作为 iOS 7 中 UISearchBar 的 subview ?

ios - iPad 2 UIImageview 显示图像不正确(渲染不正确)

xcode - 是否可以在 Storyboard 中按住 ctrl-drag 来设置 UINavigationControllerDelegate?

xcode - 恢复文件文档基础应用程序

ios - 摆脱 SIGABRT 错误

ios - 如何将带有枚举键的 Swift 字典转换为 NSDictionary?

ios - 无法在具有@objc 属性的协议(protocol)中使用自定义类?

ios: mapkit 如何在 map 上启用当前位置按钮?

iphone - 在导航栏iPhone上设置自定义后退按钮,有时会在顶部显示后退按钮