使用Storyboard自定义UITableViewCell - 无数据显示

时间:2013-07-01 15:48:39

标签: sqlite uitableview storyboard

我读了这个教程

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;
}

当我运行代码时,我看不到任何数据。

2 个答案:

答案 0 :(得分:1)

您是否将tableview与文件所有者相关联?确保数据源和委托都挂钩到文件所有者。

希望这会有所帮助

答案 1 :(得分:0)

确保故事板(检查员 - >标识符)和代码(CellIdentifier)中的单元格标识符匹配。

相关问题