0

项目因此错误而崩溃。

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
4

1 回答 1

2

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

于 2011-08-09T01:44:26.450 回答