2014-06-30 36 views
0

這是我的代碼和我的錯誤。我在2 customcell s的故事板中有2 tableview s。但我不能設置cellforrowatindexpath方法table2cellForRowAtIndexPath for 2 tableview in storyboard,unrecognized selector sent to instance error

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ 
    if(tableView.tag==1){ 
    static NSString *CellIndentifier = @"CustomCell"; 
    CustomCell *cell=[tableView dequeueReusableCellWithIdentifier:CellIndentifier]; 
    if (cell==nil) { 
     cell=[[CustomCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIndentifier]; 

    } 
    cell.text1Label.text=[moviesArray objectAtIndex:indexPath.row]; 
    cell.text2Label.text=[moviesArraytext2 objectAtIndex:indexPath.row]; 
     return cell; 
    } 
    else if (tableView.tag==2){ 
     static NSString *CellIndentifier2 = @"CategoryCell"; 
     CategoryCell *cell2=[tableView dequeueReusableCellWithIdentifier:CellIndentifier2]; 
     if (cell2==nil) { 
      cell2=[[CategoryCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIndentifier2]; 

     } 
     cell2.categoryLabel.text=[hotProgramByCatArray objectAtIndex:indexPath.row]; 
     return cell2; 
return nil; 

,這是錯誤:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UITableViewCell categoryLabel]: unrecognized selector sent to instance 0x8e7f560' 
+1

看起來問題在於如何創建自定義單元格,而不是您擁有2個表格視圖。 – Stonz2

+0

你在IB中設置了小區標識符嗎? – faviomob

+0

我認爲問題是有返回值。返回零是真的嗎? – HIEU

回答

0

確保了在定製單元的意見網點佈線到小區本身不是「文件所有者」。

您可以通過查看Interface Builder中的Connections Inspector進行檢查。

相關問題