ios – 如何清除UIView transitionWithView的效果

使用下面的代码,我已经成功地使我的UI ImageView在其图像中消失.
[UIView transitionWithView:myCell.myImageView duration:2.0 options:UIViewAnimationOptionTransitionCrossDissolve animations:^{
    myCell.myImageView.image = myImage;
} completion:NULL];

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

我试过了

-(void)prepareForReuse {
    [super prepareForReuse];

// More is obviously needed than just setting image to nil when using a transition
self.myImageView.image = nil;

[self.myImageView setNeedsDisplay];

// but I also tried removing all animations
[self.myImageView.layer removeAllAnimations];

// and I even tried removing the sublayers,but still no success.
[self.myImageView.layer.sublayers makeObjectsPerformSelector:@selector(removeFromSuperlayer)];
}

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

谢谢!

解决方法

你可以利用回调

的tableView:didEndDisplayingCell:forRowAtIndexPath:

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

以上是来客网为你收集整理的ios – 如何清除UIView transitionWithView的效果全部内容,希望文章能够帮你解决ios – 如何清除UIView transitionWithView的效果所遇到的程序开发问题。

如果觉得来客网网站内容还不错,欢迎将来客网网站推荐给程序员好友。