ios - 如何去除 UIView transitionWithView 的效果

标签 ios objective-c uiview calayer

使用下面的代码,我已经成功地使我的 UIImageView 在其图像中淡出。

[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 的效果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28535466/

相关文章:

ios - 随机删除自定义 UIView Not Working swift 3

带有 CoreLocation 的 iOS 地理围栏

objective-c - 导航栏设置为不可见,但单击后退按钮时会出现

iphone - UITap手势识别器

iOS后台获取自定义间隔

objective-c - 过滤我使用 NSSearchField 加载核心数据的数据

ios - UIScrollView 标题 View ?

iphone - AVErrorInvalidVideoComposition = -11841

ios - GStreamer 中架构 arm64 的 undefined symbol

ios - UIImage 上的类别返回一个空白的 UIImage?