2012-08-02 34 views
-1

我有一个表格视图,其中每个单元格都添加了一个对象。现在在cellForRowAtIndexPath我想根据对象做一些GUI操作。例如。桌面视图如何工作 - IOS?

static NSString *CellIdentifier = @"Cell"; 

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
if (cell == nil) { 
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier]; 
} 

    // Got object. 
    modal_info *obj = [self.listData objectAtIndex: [indexPath row]]; 

    if (obj->status != OFI_VC_USER_STATE_HEADING) 
    { 
     cell.textLabel.text = obj->combined_name; 
     cell.detailTextLabel.text = obj->email; 

     // Set Image 
     UIImage *cellImage = [UIImage imageNamed:@"silhouette_user.png"]; 
     cell.imageView.image = cellImage; 
    } else { 
     cell.imageView.image = nil; 
     cell.detailTextLabel.text = nil; 
     cell.textLabel.text = nil; 
    } 
    return cell; 

但在表格视图名称和图像显示标题行即使我设置为零。我做错了什么?

在此先感谢。

+0

是否要将图像添加到节标题 – 2012-08-02 05:47:10

+0

您不应该直接访问具有结构访问运算符(' - >')的iVar。改用属性。 – CodaFi 2012-08-02 05:49:56

+0

@neon samuel我修复了它。它是我的错误,我在添加时没有正确设置值。不管怎么说,还是要谢谢你。 :) – Feroz 2012-08-02 05:50:31

回答

0

@neon samuel我已修复它。它是我的错误,我在添加时没有正确设置值。不管怎么说,还是要谢谢你。 :) - Feroz Mohideen