我開始在Xcode 4.2的單一視圖模板(最近升級到4.2的Xcode和iOS5的)視圖控制器
所以現在我只有一個視圖控制器。
我在UIViewcontroller的子類中添加了一個新類。
現在在主控制器類viewDidLoad方法
- (void)viewDidLoad
{
// Override point for customization after application launch.
[super viewDidLoad];
[self presentQuizcontroller];
}
-(void) presentQuizcontroller
{
_QuizController = [[[Quiz alloc] initWithNibName:@"Quiz" bundle:nil] autorelease];
_QuizController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:_QuizController animated:YES]; // Do any additional setup after loading the view, typically from a nib.
}
問題是在我的測驗類
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
的initWithNibName方法不會被調用(我檢查用的斷點),但它不」 t通過if(self)的條件。因此視圖不會出現。
任何想法?
編輯
第一個答案我想這太
- (void)viewDidLoad
{
// Override point for customization after application launch.
[super viewDidLoad];
}
-(void) presentQuizcontroller
{
_QuizController = [[[Quiz alloc] initWithNibName:@"Quiz" bundle:nil] autorelease];
_QuizController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:_QuizController animated:YES]; // Do any additional setup after loading the view, typically from a nib.
}
-(void) awakeFromNib
{
[self presentQuizcontroller];
}
同樣的事情Quiz.m initwithnib名稱方法後,如果(個體經營)不通過的情況。