我正在开发一款适用于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
我真的没有在这里看到的任何问题,所以我假设它是与我重新连接视图控制器的视图。我没有我正在使用的实际视图文件,只是视图控制器。任何人都可以帮忙吗?
好的,我检查了这个位置,主要的笔尖文件的基本名称是MainWindow。我没有弄错窗口,只是视图控制器的视图。尝试更改文件基本名称只会导致崩溃。 – RaysonK 2011-05-25 22:28:43
我做了一个项目的确切副本,并再次尝试,现在它工作正常。这可能是你说的信息文件中的一些东西。谢谢您的帮助! – RaysonK 2011-05-25 22:50:39