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

你正在尝试在UIViewController上initWithFrame。你将在UIView子类上使用initWithFrame。你得到的错误是正确的,因为UIViewController不会响应那个消息,因为它没有initWithFrame选择器。你可以在UIViewController中设置UIViewController的view属性框架

最新更新