- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *ID = @"cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID];
}
NSDictionary *topic = self.topics[indexPath.row];
cell.textLabel.text = topic[@"name"];
cell.detailTextLabel.text = topic[@"text"];
[cell.imageView sd_setImageWithURL:[NSURL URLWithString:topic[@"profile_image"]] placeholderImage:[UIImage imageNamed:@"defaultUserIcon"]];
return cell;
}不自定义cell,最原始的创建UITableViewCell
最新推荐文章于 2025-11-30 09:22:57 发布
本文介绍如何在UITableView中自定义UITableViewCell,并实现图片的异步加载。通过复用单元格提高应用性能,同时使用默认图标作为占位符提升用户体验。
1144

被折叠的 条评论
为什么被折叠?



