0
自2009年以來,這是我填充的tableView細胞(自定義單元格)方式:正確的方法來填充的TableView細胞
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
AccountTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"AccountCellID"];
if (cell==nil) {
cell = [[AccountTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"AccountCellID"];
}
// here update content
cell.customImg = [UIImage imageNamed:[NSString stringWithFormat:@"%ld.png",indexPath.row]]
return cell;
}
這是好事還是有更好的辦法嗎?有人說我應該更新TableViewcell自定義類中的所有內容。有什麼區別嗎?
感謝那個鑄造的好點。但是細胞數據羣體呢?如果我們在cellForRow中或單元格的自定義類本身(即在CustomCell.m/h中)執行它,這有什麼關係? – GeneCode
那麼,如果你在單元格的自定義類中執行它,那麼它將是MVC結構的完美實現。我沒有在我的系統上,所以我就這麼回答了這個錯誤的案例。 –