我有问题,我的应用程序崩溃了,cellForRowAtIdexPath
因为我想为 2 个不同的行添加 2 个不同的自定义表格视图单元格。
看我的代码。
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier1 = @"MatchDetail";
MatchDetailsCell *cell1 = [tableView dequeueReusableCellWithIdentifier:CellIdentifier1];
static NSString *CellIdentifier2 = @"GoalsList";
GoalsListCell *cell2 = [tableView dequeueReusableCellWithIdentifier:CellIdentifier2];
if(indexPath.section == 0)
{
if(indexPath.row == 0)
{
if (cell1 == nil) {
cell1 = (MatchDetailsCell *)[MatchDetailsCell cellFromNibNamed:@"MatchDetailsCell"];
}
[cell1 setDataInCell:arrAllGames :strTeamA :strTeamB];
return cell1;
}
else if (indexPath.row == 1)
{
if (cell2 == nil) {
cell2 = (GoalsListCell *) [GoalsListCell cellFromNibNamed:@"GoalsListCell"];
}
[cell2 setDataInCell:arrGoalsList :[arrAllGames count]];
return cell2;
}
}
return nil;
}