方案一:
- (void)viewDidLoad {
[_tableView registerClass:[TasteMoneyCell class] forCellReuseIdentifier:@"TasteMoneyCell"];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *identifier = @"TasteMoneyCell";
TasteMoneyCell *cell = (TasteMoneyCell *)[tableView dequeueReusableCellWithIdentifier:identifier];
[cell initWithData:_dataSourse[indexPath.row]];
return cell;
}
方案二:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *identifier = @"cell";
TasteMoneyCell *cell = (TasteMoneyCell *)[tableView dequeueReusableCellWithIdentifier:identifier];
if (!cell) {
cell = [[TasteMoneyCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
}
[cell initWithData:_dataSourse[indexPath.row]];
return cell;
}