我正在尝试实现一个“设置页面”,例如拆分视图,左侧是表格视图,右侧是图像视图。一切都很好,但是如果尝试更快地点击它,表格视图单元格触摸会出现延迟。DidSelectRowAtIndex
path 没有被调用,但单元格闪烁。
我试过的,
将图像更改逻辑移至
willSelectRowAtIndexPath
fromDidSelectRowAtIndex
从委托方法中删除所有内容(检查是否是由于加载图像)
我该如何解决这个有线问题?
表数据源
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellIdentifier = @"tutorialCell";
CustomTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil) {
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"TutorialTableCell" owner:nil options:nil];
cell = [nib objectAtIndex:0];
}
NSDictionary * dic = [dictArray objectAtIndex:indexPath.row];
cell.tutorialText.text = [dic valueForKey:TUTORIAL_TEXT];
cell.tutorialImage.image = [UIImage imageNamed:[dic valueForKey:TUTORIAL_ICON]];
cell.contentView.backgroundColor = [UIColor colorWithHex:@"#36393D" alpha:1.0];
UIView *bgColorView = [[UIView alloc] init];
[bgColorView setBackgroundColor:[UIColor colorWithHex:@"#1f1f1f" alpha:1.0]];
[cell setSelectedBackgroundView:bgColorView];
return cell;
}
表视图委托
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSDictionary * dic = [dictArray objectAtIndex:indexPath.row];
_tutorialImageView.image = [UIImage imageNamed:[dic valueForKey:TUTORIAL_IMAGE]];
}