Чтобы изменить изображение кнопки, выполните следующие действия.
Single Выбор
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
if (selectedIndex == indexPath.row) {
// change image here...
}
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
selectedIndex = indexPath.row;
[tableView reloadData];
}
Если вам нужно для множественного выбора, то вы можете сохранить массив, чтобы захватить индексы и сделать все необходимое, как показано ниже.
Множественный выбор
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
if ([selectedIndexArray containsObject:indexPath.row]) {
// change image to check mark here...
} else {
// Change image to un-check mark
}
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if ([selectedIndexArray containsObject:indexPath.row]) {
[selectedIndexArray removeObject:indexPath.row];
} else {
[selectedIndexArray addObject:indexPath.row];
}
[tableView reloadData];
}
проверить мои анс. Надеюсь, поможет. Счастливое кодирование. –
luckyShubhra