如果我在单元格中按下他,我的动画ImageView会被隐藏。但没有按钮,它不应该消失。那是我的代码:
for (int x = 9; x > 0; x = x-1) {
NSArray *imageArray = [NSArray arrayWithObjects:[UIImage imageNamed:[NSString stringWithFormat:@"%d-1.png",x]],
[UIImage imageNamed:[NSString stringWithFormat:@"%d-2.png",x]],
[UIImage imageNamed:[NSString stringWithFormat:@"%d-3.png",x]],
[UIImage imageNamed:[NSString stringWithFormat:@"%d-4.png",x]],
[UIImage imageNamed:[NSString stringWithFormat:@"%d-3.png",x]],
[UIImage imageNamed:[NSString stringWithFormat:@"%d-2.png",x]],nil];
[array addObject:imageArray];
}
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return feedArray.count;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
NSArray *contentArray = [feedArray objectAtIndex:indexPath.row];
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:[NSString stringWithFormat:@"%lu",(unsigned long)contentArray.count] forIndexPath:indexPath];
if (contentArray.count == 1) {
UIImageView *firstImageView = (UIImageView *)[cell viewWithTag:1];
firstImageView.contentMode = UIViewContentModeScaleAspectFill;
firstImageView.animationImages = [contentArray objectAtIndex:0];
firstImageView.animationDuration = 1.2;
[firstImageView startAnimating];
}
return cell;
}
有人可以帮助我吗?
非常感谢!
答案 0 :(得分:0)
您可以创建自定义collectionviewcell并覆盖setSelected:
和setHighlighted:
,如上一个答案uiimageview animation stops when user touches screen中所述。