У меня есть несколько разных ячеек в моем таблицеView, каждый с разными подзонами. Каждый раз, когда ячейка исчезает и снова появляется, субвизор добавляется поверх старого представления, а также добавляется в другие ячейки. Каков правильный способ добавления subviews в ячейки без использования пользовательских ячеек?Добавить subview в UITableViewCell: добавлено несколько раз при прокрутке
Заранее спасибо
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"StatisticsCell";
StatisticsCell *cell = (StatisticsCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
NSArray *topLevelObject = [[NSBundle mainBundle] loadNibNamed:@"StatisticsCell" owner:nil options:nil];
for (id currentObject in topLevelObject)
{
if ([currentObject isKindOfClass:[UITableViewCell class]])
{
cell = (StatisticsCell *)currentObject;
break;
}
}
}
if (indexPath.section == 0 && indexPath.row == 0)
{
//Add a subview here
[cell addsubview ....
}
else if (indexPath.section == 0 && indexPath.row == 1)
{
//Add a subview here
[cell addsubview ....
}
etc....