我剛開始實施多選UICollectionView。下面將被視爲「安全」的代碼(因爲我假設它有一些原因稱爲BackgroundView而不是AccessoryView等)?我的想法是節省一些努力,我打算跟蹤索引路徑中的選定項目,以便通過數組進一步使用。UICollectionView cell:將cell.selectedBackgroundView放在前面可以安全嗎?
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
//....
cell.selectedBackgroundView = someView_With_A_Checkmark_Image;
[cell bringSubviewToFront:cell.selectedBackgroundView];
//...
return cell;
}
聽起來不錯。對於我來說,在一個特定的情況下,我覺得這是有道理的,而不是添加到內容視圖,只是好奇,因爲它感覺很奇怪。 – ceekay 2013-03-25 15:39:49