0
我有一個UITableView,我想用它來允許多選。我將大部分功能彙集在一起,但遇到一個小問題。UITableView多選
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSLog(@"Selected");
UITableViewCell *selectedCell = [tableView cellForRowAtIndexPath:indexPath];
if ([selectedCell accessoryType] == UITableViewCellAccessoryNone) {
[selectedCell setBackgroundColor:[UIColor grayColor]];
[selectedCell setAccessoryType:UITableViewCellAccessoryCheckmark];
[[selectedCell textLabel] setTextColor:[UIColor whiteColor]];
} else {
[selectedCell setAccessoryType:UITableViewCellAccessoryNone];
[selectedCell setBackgroundColor:[UIColor clearColor]];
[[selectedCell textLabel] setTextColor:[UIColor blackColor]];
}
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
這是我使用,以保持選定單元格中的代碼,但是當用戶點擊該單元格,在aaccessory視圖變成白色,然後變成回藍。
對於我來說,讓配件視圖保持白色的最佳方式是什麼?
感謝