事情的起因呢,是因為在選中的時候cell里面的控件顏色改變了,然后測試提的bug就是,和設計圖不符???

image.png
好吧,那我能怎么辦呢,當然是改啊!
然后試過了很多辦法,類似:
1、cell.selectionStyle = UITableViewCellSelectionStyleNone;
2、[tableView deselectRowAtIndexPath:indexPath animated:YES];
3、cell.selectedBackgroundView = [[UIView alloc] init];
4、在layoutSubviews方法中再次設置控件的背景顏色
你們猜怎么樣?當然就是全部失敗了(無奈臉)
第1,2種方法設置了之后,tableview編輯狀態(tài)下就是這樣的

1,2.png
看見了嗎,前面的圓圈圈點了沒反應了~~~~~
第3,4種方法設置了之后,tableview編輯狀態(tài)下就是這樣的

3,4.png
只有前面這一點點變了,后面依舊怎樣還是怎樣,好吧,你傲嬌,我不跟你一般見識,就繼續(xù)往下找方法吧。然后我犧牲了我的午休時間,終于把這個煩人的東西給干掉了,誰也不知道會這么簡單,就兩句代碼就搞定了,你猜猜是什么,算了,你如果知道也不會上網(wǎng)搜了不是。。hhhh
分為兩步,首先,初始化cell的地方
- (UITableViewCell *)tableView:(UITableView *)tableViewcellForRowAtIndexPath:(NSIndexPath *)indexPath
{
cell.tintColor = kBLRed;
cell.selectedBackgroundView = [[UIView alloc] init];
//就這兩句代碼
cell.multipleSelectionBackgroundView = [[UIView alloc] initWithFrame:cell.bounds];
cell.multipleSelectionBackgroundView.backgroundColor = [UIColor clearColor];
return cell;
}
然后在自定義cell里面的
-(void)setSelected:(BOOL)selected animated:(BOOL)animated
方法里面重寫控件的顏色就可以了然后就會實現(xiàn)你想實現(xiàn)的效果了

image.png
api (多選情況下被選中時的背景view)
multipleSelectionBackgroundView:If not nil, takes the place of the selectedBackgroundViewwhen using multiple selection.
能怎么辦呢~ 必須要記下來