В моем TableView didSelectRowAtIndexPath обновляет только последнюю видимую ячейку таблицы на каждой ячейке.В UiTableView didSelectRowAtIndexPath обновление неправильной ячейки
Вот пример кода:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if ([tableView isEqual:subcategoryTV])
{
selCell=(MDTableViewCell *)[subcategoryTV cellForRowAtIndexPath:indexPath ];
if ([checkButton.titleLabel.text isEqualToString:@"✓"])
{
checkButton.backgroundColor=[UIColor clearColor] ;
[checkButton setTitle:resetTitle forState:UIControlStateNormal];
[checkButton setTitleColor:[UIColor clearColor] forState:UIControlStateNormal];
checkButton.layer.borderColor = [UIColor lightGrayColor].CGColor;
}
else
{
resetTitle=checkButton.titleLabel.text;
NSLog(@"%@",resetTitle);
checkButton.backgroundColor=[UIColor colorWithRed:1 green:0.839 blue:0.314 alpha:1] ;
[checkButton setTitle:@"✓" forState:UIControlStateNormal];
[checkButton.titleLabel setFont:[UIFont fontWithName:@"Futura" size:25]];
[checkButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
checkButton.layer.borderColor = [UIColor clearColor].CGColor;
}
if (costLabel.hidden==YES) {
costLabel.hidden=NO;
}
else
{
costLabel.hidden=YES;
}
}
}
Что такое checkButton и costLabel? Являются ли они кнопками и ярлыками в ячейке? Вы инициализируете 'selCell', но не используете или не модифицируете указанный код. – UditS
Я подозреваю, что 'checkButton' и' costLabel' - это свойства, которые назначаются кнопке и помечены ярлыком в ячейке в 'cellForItemAtIndexPath:'. Вот почему последняя ячейка изменяется только потому, что 'checkButton' и' costLabel' присваиваются последней кнопке и метке ячеек. –
@FahriAzimov checkButton и costLabel - это моя пользовательская кнопка и ярлык ячейки. – PalviRane