2

アニメーションを作成するために一連の画像をダウンロードしています。ダウンロードが開始されたときにアクティビティ インジケーターを表示し、終了したときにアクティビティ インジケーターを非表示にするにはどうすればよいですか。

self.img = [[UIImageView alloc] initWithFrame:CGRectMake(0, 65, self.view.frame.size.width, self.view.frame.size.width-70)];



        img.animationImages = [NSArray arrayWithObjects:

                                   [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:@"URL"]]],

                                   [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:@"URL"]]],

                                   [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:@"URL"]]],

                                   [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:@"URL"]]],




        img.animationDuration = 20.0f;

        img.animationRepeatCount = 0;

        [img startAnimating];

        [self.view addSubview: img];
4

2 に答える 2

1

ダウンロードの開始時に次のコードを記述します。 UIActivityIndi​​catorView *spinner = [[UIActivityIndi​​catorView alloc] initWithActivityIndi​​catorStyle:UIActivityIndi​​catorViewStyleGray] ; spinner.frame = CGRectMake(0, 0, 320, 50); [スピナースタートアニメーション];

ダウンロードが終了したら、次のコードを記述します:[spinner stopAnimating];

于 2015-02-14T04:45:02.233 に答える