我正在尝试让我的UITableViewCell在高亮时更改它的accessoryView.所以配件在突出显示时会变暗.到目前为止,我已经设法让它工作得非常好,只有一个例外.当按下一个单元格时,它会使单元格突出显示,但当移动该按下并取消突出显示时,accessoryView会保留其突出显示的图像.
有没有办法检测突出显示是否被取消所以我可以将accessoryView更改回应该是什么?我是否需要创建UITableViewCell的子类才能实现此目的?任何帮助是极大的赞赏.谢谢!
正常状态:

突出的国家

按下并移动触摸后(我想避免):

- (void)tableView:(UITableView *)tableView didHighlightRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
UIImageView *accessoryView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"accessoryDark.png"]];
cell.accessoryView = accessoryView;
}
- (void)tableView:(UITableView *)tableView didUnhighlightRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
UIImageView *accessoryView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"accessory.png"]];
cell.accessoryView = accessoryView;
}
Run Code Online (Sandbox Code Playgroud)