2011-08-09 52 views
0

該項目崩潰與此錯誤。iOS - 崩潰自定義視圖

2011-08-08 19:34:27.539 MCIT[12233:207] -[TrailersViewController initWithFrame:]: unrecognized selector sent to instance 0x58396e0 
2011-08-08 19:34:27.542 MCIT[12233:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[TrailersViewController initWithFrame:]: unrecognized selector sent to instance 0x58396e0' 
在這種方法

的委託

-(void)switchToTrailerOne 
{ 
    CGSize screenSize = [UIScreen mainScreen].bounds.size; 
    CGRect screenBounds = CGRectMake(0, 0, screenSize.width, screenSize.height); 
    TrailersViewController *trailersController = [[TrailersViewController alloc] initWithFrame:screenBounds]; 

    [self.navController pushViewController:trailersController animated:NO]; 
    [trailersController goToFirstTrailer]; 
} 

問題受到歡迎,但如果你想看到的代碼有問題的視圖控制器中的文件都在這裏。

http://mytheral.com/TrailersViewControllerH.html 
http://mytheral.com/TrailersViewControllerM.html 

回答

2

您正試圖在UIViewController上使用initWithFrame。你將在UIView子類上使用initWithFrame。您收到的錯誤是正確的,因爲UIViewController不會響應該消息,因爲它沒有initWithFrame選擇器。您可以在UIViewController中設置UIViewController的視圖屬性框架。

+0

是有意義的......並且也爲我提供了複製和粘貼代碼的權利。 :X – Mytheral

相關問題