ios – 如何清除UIView transitionWithView的效果

前端之家收集整理的这篇文章主要介绍了ios – 如何清除UIView transitionWithView的效果前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
使用下面的代码,我已经成功地使我的UI ImageView在其图像中消失.
  1. [UIView transitionWithView:myCell.myImageView duration:2.0 options:UIViewAnimationOptionTransitionCrossDissolve animations:^{
  2. myCell.myImageView.image = myImage;
  3. } completion:NULL];

但是,当单元格被重用时,我需要删除此图像.
重复使用时,会显示最后的图像(在重复使用之前显示),然后转换为其应该是的图像,而不是从无图像转换为应该是的图像.

我试过了

  1. -(void)prepareForReuse {
  2. [super prepareForReuse];
  3.  
  4. // More is obvIoUsly needed than just setting image to nil when using a transition
  5. self.myImageView.image = nil;
  6.  
  7. [self.myImageView setNeedsDisplay];
  8.  
  9. // but I also tried removing all animations
  10. [self.myImageView.layer removeAllAnimations];
  11.  
  12. // and I even tried removing the sublayers,but still no success.
  13. [self.myImageView.layer.sublayers makeObjectsPerformSelector:@selector(removeFromSuperlayer)];
  14. }

任何帮助不胜感激,但如果您不明白问题,请不要回答.评论,所以如果需要,我可以更好地解释.

谢谢!

解决方法

你可以利用回调

的tableView:didEndDisplayingCell:forRowAtIndexPath:

这被称为就像细胞在可见区域之外.尝试将图像设置为零或无图像.应该工作

猜你在找的iOS相关文章