將必須標記/取消標記(假設ü只需要一次一個選擇)邊框顏色連連喜歡 -
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
if(indexPath.row==self.selectedRow){
cell.borderView.layer.borderColor = [UIColor yellowColor].CGColor;
}else {
cell.borderView.layer.borderColor = [UIColor clearColor].CGColor;
}
}
只需保存/緩存選擇指數喜歡 -
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
//Unselected the prevoius selected Cell
YourCellClass *aPreviousSelectedCell= (YourCellClass*)[tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:self.selectedRow inSection:0]];
aPreviousSelectedCell.borderView.layer.borderColor = [UIColor clearColor].CGColor;
//Selected the new one-
YourCellClass *aSelectedCell = (YourCellClass*)[tableView cellForRowAtIndexPath:indexPath];
aSelectedCell.borderView.layer.borderColor = [UIColor yellowColor].CGColor;
self.selectedRow = indexPath.row;
}
你正在做的多個選擇或單個選擇... –
[細胞setShowsTouchWhenHighlighted:YES];嘗試這一個... – Jitendra