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
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您正在尝试在 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.