2013-07-01 45 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

您是否已将表格视图与文件所有者连接起来?确保数据源和委托都挂钩到文件所有者。

希望这有助于

相关问题