目录
在UICollectionViewCell中调用了如下方法,正常显示动画。但滚动UICollectionView后动画却停止了。
-(void)fq_setupAni{
//
NSMutableArray *imgMuArr=[NSMutableArray arrayWithCapacity:8];
for(int i=0;i<10;i++){
NSString *imgName=[NSString stringWithFormat:@"voiceAnimateImg%02d",i+1];
[imgMuArr addObject:[UIImage imageNamed:imgName]];
}
[self.typeImgV setAnimationImages:imgMuArr];
[self.typeImgV setAnimationDuration:0.65];
[self.typeImgV setAnimationRepeatCount:0];
[self.typeImgV startAnimating];
}
解决办法,其实很简单。就是实现willDisplayCell、didSelectItemAtIndexPath代理方法,重新调用startAnimating就可以了
-(void)collectionView:(UICollectionView *)collectionView willDisplayCell:(UICollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath{
[(FQRoomCollectionViewCell *)cell fq_startAni];
}
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
[(FQRoomCollectionViewCell *)[collectionView cellForItemAtIndexPath:indexPath] fq_startAni];
}
// FQRoomCollectionViewCell中实现以下方法
-(void)fq_startAni{
[self.typeImgV startAnimating];
}
网友评论