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 = [[TrailersViewCont开发者_如何学Goroller 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. 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.
精彩评论