我正在开发一款适用于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
我在这里没有看到任何问题,所以我假设它与我重新连接视图控制器到视图有关。我没有我正在使用的实际视图文件,只有viewcontroller。有人可以帮忙吗?
答案 0 :(得分:2)
检查[YourApp] -info.plist中“支持文件”文件夹中“主nib文件基本名称”的设置 - 如果您更改了根视图控制器的名称,则可能需要更改这里也有名字。
答案 1 :(得分:0)
由于某些奇怪的原因,我的App Delegate的引用插座已断开连接。
尝试使用应用代表的连接检查器(最右侧菜单)从委托创建引用插座到文件所有者。