2014-06-23 51 views
1

當我嘗試點擊我的應用程序中的segueway時,出現以下調試消息。無法識別的選擇器發送到實例setDetailModal

"SmokingPig[13840:c07] -[UIViewController setDetailModal:]: unrecognized selector sent to instance 0x75836c0" 

這是我TableViewController.m文件(或我認爲部分至少搞砸)

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 
if ([[segue identifier] isEqualToString:@"ShowDetails"]) { 
    DetailViewController *detailviewcontroller = [segue destinationViewController]; 

    NSIndexPath *myIndexPath = [self.tableView indexPathForSelectedRow]; 

    int row = [myIndexPath row]; 
    detailviewcontroller.DetailModal = @[_Title[row], _Description[row]]; 
} 

這是我DetailViewController.h文件 #進口

@interface DetailViewController : UIViewController 

@property (strong, nonatomic) IBOutlet UILabel *TitleLabel; 
@property (strong, nonatomic) IBOutlet UILabel *DescriptionLabel; 

@property (strong, nonatomic) NSArray *DetailModal; 

@end 

回答

2

該segue指向通用UIViewController的實例,而不是您的DetailViewController。如果在IB中描述了segue,請選擇segue的目標端上的視圖控制器,然後使用身份檢查器(從左邊開始的第三個檢查器)並確保將自定義類設置爲DetailViewController。

你可能在這條線得到一個警告,太:

DetailViewController *detailviewcontroller = [segue destinationViewController]; 

修復與鑄造:

DetailViewController *detailviewcontroller = (DetailViewController *)[segue destinationViewController]; 
相關問題