-1

如何将四个图像放在 UIImageView 数组中?为什么我的forloop不能运行?

如果我想用四个图像创建四个帧,该怎么做?

    NSArray *photos = [NSArray arrayWithObjects:
                    [UIImage imageNamed:@"1.jpg"],
                    [UIImage imageNamed:@"2.jpg"],
                    [UIImage imageNamed:@"3.jpg"],
                    [UIImage imageNamed:@"4.jpg"],nil]; 




    for(int i=0;i<5;i++)
   {
    UIImage *image = [UIImage imageNamed:[photos objectAtIndex:i]];
    UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
   }
4

2 回答 2

0
NSArray *photos = [NSArray arrayWithObjects:
                    [UIImage imageNamed:@"1.jpg"],
                    [UIImage imageNamed:@"2.jpg"],
                    [UIImage imageNamed:@"3.jpg"],
                    [UIImage imageNamed:@"4.jpg"],nil]; 
UIImageView *imgView = [[UIImageView alloc]init];
imgView.animationImages = photos;
于 2012-11-24T09:23:10.187 回答
0

[photos objectAtIndex:i]这个方法你只能得到 UIImage 对象,你不能得到一个 NSString 对象的[UIImage imageNamed:]方法。

于 2015-11-02T02:25:21.010 回答