我必須實現國際象棋風格網格視圖來顯示一些徑向進度條。 Uicollectionview國際象棋風格網格
我使用一些低效的算法來做到這一點,因爲UiCollectionView不使用的行和列進行的網格,它的工作,但是當用戶滾動收集到了極限和收集的「行」從屏幕消失並且用戶釋放屏幕並且UICollectionViewCells再次出現,他們切換其顏色。
我知道BOOL切換髮生了,但我不知道如何解決這個問題。
這是我的算法(我有2個型動物UICollectionViewCells,每一種顏色)
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
static NSString *identifier = @"Cell";
static NSString *identifierPair = @"CellPair";
UICollectionViewCell *cell ;
UILabel *title;
//...Creating the circle progress bar....
if ((indexPath.item % 2) == 0) {
if (isPair) {
cell = [collectionView dequeueReusableCellWithReuseIdentifier:identifierPair forIndexPath:indexPath];
isPair = NO;
title = (UILabel *)[cell viewWithTag:12];
}
else
{
cell = [collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath];
isPair = YES;
title = (UILabel *)[cell viewWithTag:11];
}
}
else {
if (isUneven) {
cell = [collectionView dequeueReusableCellWithReuseIdentifier:identifierPair forIndexPath:indexPath];
isUneven = NO;
title = (UILabel *)[cell viewWithTag:12];
}
else
{
cell = [collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath];
isUneven = YES;
title = (UILabel *)[cell viewWithTag:11];
}
}
//...Setting the name to the cell....
return cell;
}
計數是否改變?當他們達到100%時你是否將其移除?當一行被添加或刪除時,你是否全部更新了它們?難道你不想只是總是在光明與黑暗之間交替(例如,即使是光明與奇怪的黑暗)? – 2014-10-02 17:27:08
這個圓圈是靜態的(我用它只是爲了向用戶顯示信息),它們不會被用戶刪除或添加 – 2014-10-02 17:40:28