-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;
但在表格視圖名稱和圖像顯示標題行即使我設置爲零。我做錯了什麼?
在此先感謝。
是否要將圖像添加到節標題 – 2012-08-02 05:47:10
您不應該直接訪問具有結構訪問運算符(' - >')的iVar。改用屬性。 – CodaFi 2012-08-02 05:49:56
@neon samuel我修復了它。它是我的錯誤,我在添加時沒有正確設置值。不管怎麼說,還是要謝謝你。 :) – Feroz 2012-08-02 05:50:31