0

当方iPhone初心者で、画像は全て配列にしていますが、配列をループ実行した際に1枚ずつ表示する方法は..

NSArray *images = [[NSArray arrayWithObjects:   
                        [UIImage imageNamed:@"1.png"],
                        [UIImage imageNamed:@"2.png"],
                        [UIImage imageNamed:@"3.png"],
                        [UIImage imageNamed:@"4.png"],
                        nil] retain];  


 int i=0;
    int width = 0;
    int height = 0;
    for ( NSString *imageName in images )
    {
        //NSTimer *timer=[[NSTimer alloc]init];
        UIImage *image = [images objectAtIndex:i];
        //UIImage *image = [UIImage imageNamed:imageName];
        animalphoto = [[UIImageView alloc] initWithImage:image];
        animalphoto.contentMode = UIViewContentModeScaleAspectFit;
        animalphoto.clipsToBounds = YES;



        animalphoto.animationDuration=5.0;
        animalphoto.animationRepeatCount=0;

        animalphoto.frame = CGRectMake( animalphoto.frame.size.width * i++, 0, animalphoto.frame.size.width, animalphoto.frame.size.height);


       width = animalphoto.frame.size.width;
        height = animalphoto.frame.size.height;
        NSLog(@"print:%@",image);
        [animalphoto release];
    }


}

私たちのコードに適用される提案とサンプルコードを教えてください..

4

2 に答える 2

1

1 つの画像を配置する代わりに、画像の配列全体を for ループなしで imgview.animationImages = images に配置します。

詳細については、このサイトを参照してください。

于 2012-07-05T11:15:18.510 に答える
0

UIImageView'sオブジェクトを使用animationImagesしてUIImage配列
セットをanimationRepeatCount
設定しanimationDuration
、呼び出し[imageView startAnimating];てアニメーションを開始する必要があります

于 2012-07-05T11:15:17.837 に答える