カスタムコレクションビューのセル(アイテム)があります。私は各項目に多くのUILabels
があります。サーバーのデータによっては、ラベルを適切に更新したいと考えています。対応する項目をリロードしてデータを更新すると正常に動作します。コード:cellForItemAtIndexPath
方法でUICollectionViewCellでUILabelのUIViewアニメーションブロックが機能しない
isUpdate = YES;
[_collectionView performBatchUpdates:^{
[_collectionView reloadItemsAtIndexPaths:bufferUpdateRow];
} completion:^(BOOL finished) {}];
、私は変更をチェックし、いずれかが存在する場合、私は、アニメーションブロックを使用したいが、それは動作していないようです。
-(UICollectionViewCell*)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
static NSString *cellID = @"CellID";
CollectionViewCell *cell = (CollectionViewCell*)[collectionView dequeueReusableCellWithReuseIdentifier:cellID forIndexPath:indexPath];
// Update label content here
if (isUpdate) {
_label1.layer.backgroundColor = [UIColor redColor];
[UIView animateWithDuration:1 delay:0 options:UIViewAnimationOptionAllowUserInteraction animations:^(void) {
_label1.layer.backgroundColor=[UIColor clearColor].CGColor;
} completion:nil];
isUpdate = NO;
}
return cell;
}
ラベルが赤く点滅しません。代わりに、それは明らかに残っています。アニメーションブロックを削除すると、ラベルが赤くなります(更新検出が正常に動作していることがわかります)。 Plsヘルプ
これは機能します。ありがとうございました! – GeneCode