2009-04-07 67 views
5

添加:(id)發件人後,我收到了此例程的崩潰,因此我可以確定哪個按鈕調用了它。當設置爲普通舊版toggleView3時,它可以很好地工作。當detailView切換回docView時發生崩潰。NSInvalidArgumentException

'NSInvalidArgumentException', reason: '*** -[RootViewController toggleView3]: unrecognized selector sent to instance 0x524a00' 2009-04-07 12:29:44.421 eTarot[11405:20b] Stack:

-(IBAction)toggleView3:(id)sender{ 


    if (detailViewController == nil) { 
     [self loadDetailViewController]; 
    } 

    UIView *docView = docViewController.view; 
    UIView *detailView = detailViewController.view; 

    [UIView beginAnimations:nil context:NULL]; 
    [UIView setAnimationDuration:1]; 
    [UIView setAnimationTransition:([docView superview] ? UIViewAnimationTransitionFlipFromRight : UIViewAnimationTransitionFlipFromLeft) forView:self.view cache:YES]; 

    if ([docView superview] != nil) { 
     [detailViewController viewWillAppear:YES]; 
     [docViewController viewWillDisappear:YES]; 
     [docView removeFromSuperview]; 

     [self.view addSubview:detailView]; 
     [self.view insertSubview:detailNavigationBar aboveSubview:detailView]; 
     [docViewController viewDidDisappear:YES]; 
     [detailViewController viewDidAppear:YES]; 

    } else { 
     [docViewController viewWillAppear:YES]; 
     [detailViewController viewWillDisappear:YES]; 
     [detailView removeFromSuperview]; 
     [detailNavigationBar removeFromSuperview]; 
     [self.view addSubview:docView]; 
     [detailViewController viewDidDisappear:YES]; 
     [docViewController viewDidAppear:YES]; 
    } 
    [UIView commitAnimations]; 
} 
+0

你可以發佈調用toggleView3的代碼嗎? – cobbal 2009-04-07 17:24:20

回答

13

當正確的選擇器名稱是toggleView3: - 即冒號和參數時,您正在發送視圖toggleView3。它們可能看起來與你類似,但它們與Objective-C完全不同。

+0

謝謝Chuck。很明顯,一旦它指出:) – Alan 2009-04-07 17:44:20

2

這異常意味着您的應用程序而無需調用toggleView3:發件人的說法地方。由於您的新方法需要參數,因此與調用從未存在的方法相同。

如果您在調試器中查看堆棧跟蹤,應該很清楚它來自哪裏。構建結果中也可能有警告。

相關問題