2013-07-01 48 views
0

我閱讀本教程自定義的UITableViewCell與故事板 - 沒有數據顯示

ios-programming-customize-uitableview-storyboard
實現自定義的UITableViewCell。

在經典視圖中的數據被正確地顯示和更改這部分代碼:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
    static NSString *CellIdentifier = @"Cell"; 


    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 

    if (cell == nil) { 
     cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; 
    } 

    ItemObject *obj=[[restArray objectAtIndex:indexPath.row] retain]; 


    UILabel *objNameLabel = (UILabel *)[cell viewWithTag:101]; 
    objNameLabel.text =obj.rag_soc; 

    UILabel *objDetailLabel = (UILabel *)[cell viewWithTag:102]; 
    objDetailLabel.text=obj.via; 

    UIImageView *imv = [[UIImageView alloc]initWithFrame:CGRectMake(3,2, 44, 44)]; 
    imv.image=[UIImage imageNamed:@"web_new.png"]; 
    [cell.contentView addSubview:imv]; 
    [imv release]; 

    NSLog(@"%d",obj.nArrayIndex); 
    [obj release]; 



    return cell; 
} 

當我運行該代碼我沒有看到任何數據。

+0

你做在Interface Builder中的所有步驟,如創建標籤和ImageView的,給他們適當的標籤,否則你的代碼將不引用任何東西 –

回答

0

確保故事板(檢查器 - >標識符)和代碼(CellIdentifier)中的單元格標識符匹配。

1

您是否已將表格視圖與文件所有者連接起來?確保數據源和委託都掛鉤到文件所有者。

希望這有助於

相關問題