簡體   English   中英

uitableview中的多項選擇-dequeueReusableCellWithIdentifier導致問題

[英]multiple selection in uitableview - dequeueReusableCellWithIdentifier is causing issue

//selected rows is mutablearray
if (aCell.accessoryType == UITableViewCellAccessoryCheckmark) {
  [selectedRows addObject:indexPath];
 }

這里的問題是當我滾動uitableview時,所有選擇都搞砸了。 跟蹤選定單元格的最佳方法是什么? 我也不想使用復選標記,我只想更改所選行的背景顏色。

如果要更改選定單元格的選定顏色。 cell.selectedcolor = [uicolor blackcolcor]; 或者您可以使用此方法更改自定義tableeview單元格的背景顏色

UIView *bgColorView = [[UIView alloc] init];
[bgColorView setBackgroundColor:[UIColor redColor]];
[cell setSelectedBackgroundView:bgColorView];
[bgColorView release];

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM