2011-05-25 74 views
2

我正在開發一款適用於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 

我真的沒有在這裏看到的任何問題,所以我假設它是與我重新連接視圖控制器的視圖。我沒有我正在使用的實際視圖文件,只是視圖控制器。任何人都可以幫忙嗎?

回答

2

檢查[YourApp] -info.plist中的「支持文件」文件夾中的「主筆尖文件基本名稱」的設置 - 如果您更改了根視圖控制器的名稱,則可能需要更改這裏的名字也是如此。

+0

好的,我檢查了這個位置,主要的筆尖文件的基本名稱是MainWindow。我沒有弄錯窗口,只是視圖控制器的視圖。嘗試更改文件基本名稱只會導致崩潰。 – RaysonK 2011-05-25 22:28:43

+1

我做了一個項目的確切副本,並再次嘗試,現在它工作正常。這可能是你說的信息文件中的一些東西。謝謝您的幫助! – RaysonK 2011-05-25 22:50:39

0

由於某些奇怪的原因,我的App Delegate的參考插座斷開連接。

嘗試使用連接檢查器(最右側菜單)爲您的應用程序委託創建一個從代理到文件所有者的引用插座。