を使用してUIImageView
、静止画像とアニメーション画像の両方を表示しています。だから時々、私は使用 .image
して.animationImages
います。これで問題ありません。
静的であろうとアニメーションであろうと、私は を格納しUIImages
ますitem.frames
(以下を参照)
UIActivityIndicatorView
問題は、アニメーション フレームの読み込み中にビューの中央にa を表示したいということです。画像やフレームを入れずにこれを実現したいと思います。本来の動作をしていない行は次のとおりです。
[self.imageView removeFromSuperview];
実際のところ、この時点で別の画像に設定しても何も起こりません。ここでは UI の処理は行われていないようです。ところで、
NSLog(@"%@", [NSThread isMainThread]?@"IS MAIN":@"IS NOT");
印刷しIS MAIN
ます。
そこにある画像は、新しいアニメーション フレームがすべてそこにある (1 ~ 2 秒) まで残り、アニメーションが開始されます。
これはすべて、UIImageView をサブビューとして UIView のサブクラスから実行されています。
- (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];
}
私の無知な評価は、その画像が nil に設定されると、何かが再描画されていないということです。手が大好きです。