2011-08-08 9 views
0

クラッシュ:iOSの - からNavController&カスタムビュー

- [UIImageView setParentViewController:]:「 - [UIImageView setParentViewController:認識されていないセレクタが原因キャッチされないexecption 'NSInvalidArgumentExecption'、理由にインスタンスに0x58701e * Termintatingアプリを送りました:]:インスタンスに送信された認識できないセレクタ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]; 
} 

私が離れた時間で1時間、その後多くのためのコンプからほとんどないよないように見える他のコードについて掲載していません。

編集:このファイルは、あなたが関心を持っている特定のセクションは少し長めですか?私はそれはあなたがカスタムUIViewではなく、カスタムUIViewControllerをプッシュしようとしているかのように見えるのです、私はおそらく見つける少数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; 
} 
+0

興味深い。 TrailersViewController .h&.mファイルを投稿すれば、すべてがここに表示されるため、役立ちます。 –

答えて

1

を投稿します。クラス階層TrailersViewControllerを確認してください。

+0

@interface TrailersViewController:UIViewController { 何か不足していますか? – Mytheral

+0

正しいと思われます。おそらく、何かがTrailersViewControllerのloadViewで間違っていますか? – codelark

+0

問題はあなたのinitwithframeにあります。あなたは自分自身を '[super.view initWithFrame:...]'に設定しています。これは、スーパークラスではなく、ビューの初期化子を意図して呼び出すことで自分自身を初期化することを意味します。 – codelark

関連する問題