的崩潰:的iOS - NavController和自定義視圖
- [UIImageView的setParentViewController:]:無法識別的選擇發送到實例0x58701e * Termintating應用程序由於未捕獲的execption 'NSInvalidArgumentExecption',原因是:「 - [UIImageView的setParentViewController :]:無法識別的選擇發送到實例0x58701e0'
這發生在我試圖推送一個自定義的UIViewController沒有IB。
當我用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;
}
有趣。如果你可以發佈你的TrailersViewController .h&.m文件,這將有所幫助,因爲一切看起來都在這裏。 –