我正在使用 aUIImageView
来显示静止图像和动画图像。所以有时,我正在使用 .image
,有时我正在使用.animationImages
. 这可以。
无论是静态的还是动画的,我都将UIImages
's 存储在item.frames
(见下文)
问题是我想UIActivityIndicatorView
在加载动画帧时在视图的中心显示一个。我希望在没有图像或框架的情况下发生这种情况。没有做它应该做的行是:
[self.imageView removeFromSuperview];
事实上,此时将其设置为另一个图像也无济于事。似乎这里没有发生任何 UI 内容。顺便提一句,
NSLog(@"%@", [NSThread isMainThread]?@"IS MAIN":@"IS NOT");
打印IS MAIN
。
那里的图像将一直存在,直到新的动画帧都在那里(1-2 秒)并且它们开始动画
这一切都是从 UIView 的子类运行的,其中 UIImageView 作为子视图。
- (void)loadItem:(StructuresItem *)item{
self.imageView.animationImages = nil;
self.imageView.image = nil;
[self.spinner startAnimating];
self.item = item;
if (item.frameCount.intValue ==1){
self.imageView.image = [item.frames objectAtIndex:0];
self.imageView.animationImages = nil;
}else {
[self.imageView removeFromSuperview];
self.imageView =[[UIImageView alloc] initWithFrame:self.bounds];
[self addSubview:self.imageView ];
if( self.imageView.isAnimating){
[self.imageView stopAnimating];
}
self.imageView.animationImages = item.frames;
self.imageView.animationDuration = self.imageView.animationImages.count/12.0f;
//if the image doesn't loop, freeze it at the end
if (!item.loop){
self.imageView.image = [self.imageView.animationImages lastObject];
self.imageView.animationRepeatCount = 1;
}
[self.imageView startAnimating];
}
[self.spinner stopAnimating];
}
我无知的评估是,一旦该图像设置为零,就不会重绘某些东西。会喜欢一只手。