【发布时间】:2017-05-15 08:22:03
【问题描述】:
我创建一个 UIImageView 并添加到 VC UIView ,然后我创建一个带有 animatedImageWithImages:duration: 的图像
当我执行代码时,它可以正常工作。它显示图像动画。但是当我推送到下一个 VC 并在向后滑动的过程中,我发现 UIImageView 什么都没有显示。 此刻手指离开屏幕,一切恢复正常。
这是我的代码:
- (void)viewDidLoad {
[super viewDidLoad];
UIImageView *imgView = [[UIImageView alloc] init];
imgView.backgroundColor = [UIColor orangeColor];
imgView.frame = CGRectMake(20, 200, 80, 80);
[self.view addSubview:imgView];
NSArray *imgs = @[[UIImage imageNamed:@"img1"],[UIImage imageNamed:@"img2"]];
imgView.image = [UIImage animatedImageWithImages:imgs duration:0.5];
}
我注意到 imageView 有 CAKeyframeAnimation。我猜是runmode和CAKeyframeAnimation的冲突。
SDWebImage 也有同样的问题。因为它也使用了创建 UIImage 的方法。我认为重点是animatedImageWithImages:duration:和CAKeyframeAnimation的方法。
有人知道解决办法吗?非常感谢。
手指离开屏幕的事件会使imageView正常显示。为什么以及如何解决?
【问题讨论】:
-
你在 viewWillAppear 上试过了吗??
-
尝试在 viewWillAppear 委托中加载图像,这将得到解决。
-
它不起作用。 viewWillAppear 已运行,但在手指左屏幕上不显示任何内容。我认为关键是手指离开屏幕的那一刻会发生什么?
标签: ios uiimageview uiimage gif sdwebimage