iOS – 导航和自定义视图

碰撞:

– [UIImageView setParentViewController:]:无法识别的select发送到实例0x58701e * termintating由于未捕获的应用'NSInvalidArgumentExecption',原因:' – [UIImageView setParentViewController:]:无法识别的select发送到实例0x58701e0'

这发生在我试图推送没有IB的自定义UIViewController。

当我用IB来做这件事的时候,它并不是我所需要的。

什么是要求我的代表

-(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]; (Crashes on this line) [trailersController gotoFirstTrailer]; } 

向我询问任何其他代码,看起来我几乎从来没有离开过一个小时以上的时间。

编辑:文件有点长,你感兴趣的特定部分? 我会张贴我觉得有可能的几个canidates

 -(void)loadView{ CGSize screenSize = [UIScreen mainScreen].bounds.size; CGRect screenBounds = CGRectMake(0, 0, screenSize.width, screenSize.height); myTrailersView = [[UIImageView alloc] initWithFrame:screenBounds]; myTrailersView.autoresizesSubviews = YES; self.view = myTrailersView; } //Initiation Method - (void)viewDidLoad { [super viewDidLoad]; //self.myTrailersView.frame = self.view.frame; //Turn User Interaction ON - UI Image Views are Off By Default myTrailersView.userInteractionEnabled = YES; //Set Position Counters to starting values currentNode = 0; currentPosition = 0; //Allocate the Node Collection nodeCollection = [NodeSet alloc]; //Copy the Node Collection to the Receiver Array nodeArray = nodeCollection.createNodeList; //Done With Node Collection Release it [nodeCollection release]; // //Create the button that launches the cutaway view // UIBarButtonItem *rotationButton = [[UIBarButtonItem alloc] initWithTitle:@"Cutaway View" style:UIBarButtonItemStylePlain target:self action:@selector(gotoRotationView)]; self.navigationItem.rightBarButtonItem = rotationButton; [rotationButton release]; ////////Setup the Swipe Forward Recognizer//////// UISwipeGestureRecognizer *recognizerUp; recognizerUp = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom:)]; [recognizerUp setDirection:(UISwipeGestureRecognizerDirectionUp)]; [myTrailersView addGestureRecognizer:recognizerUp]; [recognizerUp release]; ////////Setup the Swipe Backward Recognizer//////// UISwipeGestureRecognizer *recognizerDown; recognizerDown = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom:)]; recognizerDown.direction = UISwipeGestureRecognizerDirectionDown; [myTrailersView addGestureRecognizer:recognizerDown]; [recognizerDown release]; ////////Setup the Swipe Left Recognizer//////// UISwipeGestureRecognizer *recognizerLeft; recognizerLeft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom:)]; recognizerLeft.direction = UISwipeGestureRecognizerDirectionLeft; [myTrailersView addGestureRecognizer:recognizerLeft]; [recognizerLeft release]; ////////Setup the Swipe Right Recognizer//////// UISwipeGestureRecognizer *recognizerRight; recognizerRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom:)]; recognizerRight.direction = UISwipeGestureRecognizerDirectionRight; [myTrailersView addGestureRecognizer:recognizerRight]; [recognizerRight release]; } - (id)initWithFrame:(CGRect)frame { self = [super.view initWithFrame:frame]; return self; } 

这看起来好像你试图推送一个自定义的UIView而不是一个自定义的UIViewController 。 检查TrailersViewController类的层次结构。