iOS - 自定义视图崩溃

发布于 2024-11-28 23:24:31 字数 1006 浏览 0 评论 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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

心房的律动 2024-12-05 23:24:31

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

You are trying to initWithFrame on a UIViewController. You will use initWithFrame on UIView subclasses. The error you are getting is correct because UIViewController won't respond to that message because it doesn't have an initWithFrame selector. You can set the UIViewController's view property frame within the UIViewController.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文