我試圖讓我的UITableViewCell更改它的附件突出顯示。所以突出顯示時附件較暗。除了一個例外,我已經設法使它工作得很好。當一個單元格被按下時,它會導致單元格突出顯示,但是當該按鍵被移動並且突出顯示被取消時,accessoryView會保留突出顯示的圖像。更改UITableViewCell突出顯示的附件
是否有任何方法檢測突出顯示是否被取消,因此我可以將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;
}
:
亮狀態
按下並移動觸摸(想什麼,我避免)後
謝謝!我最終使用'UIImageView'與'突出顯示圖像集'。你對'didUnhighlightRowAtIndexPath'中的indexPath也是正確的,但我最終沒有使用它,因爲UIImageView是更簡單的解決方案。 – bvogelzang