Я пытаюсь сделать UITableView, который добавляет галочку в выбранную ячейку, что происходит, так это то, что она добавляет галочку, но не сразу, она показывает ее, когда я выбираю другой ряд. Любая идея, как я могу сделать это мгновенно? Это мой код:iOS - UITableViewCell не отображает галочку после ее выбора
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Contact";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
NSLog(@"%@", [[self.contacts objectAtIndex:indexPath.row] valueForKeyPath:@"TwitterFriend.screen_name"]);
cell.textLabel.text = [[self.contacts objectAtIndex:indexPath.row] valueForKeyPath:@"TwitterFriend.screen_name"];
if ([self.selectedContacts containsObject:[self.contacts objectAtIndex:indexPath.row]]) {
cell.accessoryType = UITableViewCellAccessoryCheckmark;
} else {
cell.accessoryType = UITableViewCellAccessoryNone;
}
return cell;
}
- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath {
[self.selectedContacts addObject:[self.contacts objectAtIndex:indexPath.row]];
[self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationNone];
}
Вы можете попробовать поставить эту логику в 'tableView: didSelectRowAtIndexPath' вместо' tableView: didDeselectRowAtIndexPath'. – warrenm
Что? Вы знаете, что дважды вставили один и тот же метод? : P – 8vius
Подробнее. – warrenm