Fixed thanks to zbMax. I had a gesture recognizer implemented in my viewDidLoad method.
Need to stay clicked on row to select it
-
31-07-2022 - |
سؤال
I have an issue with my UITableView.
The method "didSelectRowAtIndexPath" is not called until I stay clicked on the row for 2 seconds minimum. If I just click one time on the cell like a normal person would do to select it, nothing happens : didSelectRowAtIndexPath isn't called.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"CellWithSelection" forIndexPath:indexPath];
NSDictionary *player = _objects[indexPath.row];
cell.textLabel.attributedText = [TCUtilities defaultAttributedStringWithString:[player objectForKey:@"personalName"] AndSize:DEFAULT_SIZE AndColor:DEFAULT_TEXT_COLOR];
cell.textLabel.textAlignment = NSTextAlignmentCenter;
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
[cell setBackgroundColor:[UIColor grayColor]];
[cell setAccessoryType:UITableViewCellAccessoryCheckmark];
}
- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
[cell setBackgroundColor:[UIColor clearColor]];
[cell setAccessoryType:UITableViewCellAccessoryNone];
}
المحلول
لا تنتمي إلى StackOverflow