简体   繁体   English

iOS - 崩溃自定义视图

[英]iOS - Crashing Custom View

The Project is Crashing with this error. 该项目因此错误而崩溃。

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'

in this method on the delegate 在这个方法上委托

-(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];
}

Questions are welcomed, but if you'd like to see the code the offending view controller files are here. 欢迎提出问题,但如果您希望查看代码,那么有问题的视图控制器文件就在这里。

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

You are trying to initWithFrame on a UIViewController. 您正在尝试在UIViewController上使用initWithFrame。 You will use initWithFrame on UIView subclasses. 您将在UIView子类上使用initWithFrame。 The error you are getting is correct because UIViewController won't respond to that message because it doesn't have an initWithFrame selector. 您获得的错误是正确的,因为UIViewController不会响应该消息,因为它没有initWithFrame选择器。 You can set the UIViewController's view property frame within the UIViewController. 您可以在UIViewController中设置UIViewController的视图属性框架。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM