5

我需要在单个视图中显示图像数组,这些图像在 icarousel 中具有各种效果(时间机器、coverflow 等...)我将使用必须显示所有图像的单一样式.. 这是我的代码.M 文件..

UIImage *img=[[UIImageView alloc]initWithFrame:CGRectMake(30, 30, 290, 400)];
NSLog(@"hi");

img.image=[NSArray arrayWithObjects:[UIImage imageNamed:@"Cover_0.png"],
                      [UIImage imageNamed:@"Cover_1.png"],
                      [UIImage imageNamed:@"Cover_2.png"],
                      [UIImage imageNamed:@"Cover_3.png"],
                      [UIImage imageNamed:@"Cover_4.png"],
                      [UIImage imageNamed:@"Cover_5.png"],
                      [UIImage imageNamed:@"Cover_6.png"],
                      [UIImage imageNamed:@"Cover_7.png"],nil];

但它不起作用......任何人都可以帮助它......

4

3 回答 3

6

更新:根据您的最新编辑,您的问题完全改变了,因此我的回答不适用。


改用animationImages

UIImageView *img=[[UIImageView alloc]initWithFrame:CGRectMake(30, 30, 290, 400)];
img.animationImages=[NSArray arrayWithObjects:[UIImage imageNamed:@"Cover_0.png"],
                      [UIImage imageNamed:@"Cover_1.png"],
                      [UIImage imageNamed:@"Cover_2.png"],
                      [UIImage imageNamed:@"Cover_3.png"],
                      [UIImage imageNamed:@"Cover_4.png"],
                      [UIImage imageNamed:@"Cover_5.png"],
                      [UIImage imageNamed:@"Cover_6.png"],
                      [UIImage imageNamed:@"Cover_7.png"],nil];

来自UIImageView 文档

animationImages

用于动画的 UIImage 对象数组。

@property(nonatomic, copy) NSArray *animationImages

讨论 该数组必须包含 UIImage 对象。您可以在数组中多次使用相同的图像对象。将此属性设置为 nil 以外的值会隐藏由 image 属性表示的图像。此属性的值默认为 nil。

可用性 适用于 iOS 2.0 及更高版本。另请参见 @property image @property contentMode (UIView) 在 UIImageView.h 中声明

于 2012-06-21T09:53:00.747 回答
2

你有没有尝试过

   NSArray *frames = [NSArray arrayWithObjects:
   [UIImage imageWithName:@"a.png"],
   [UIImage imageWithName:@"b.png"],
   [UIImage imageWithName:@"c.png"],
   [UIImage imageWithName:@"d.png"],
   [UIImage imageWithName:@"e.png"],
   nil];

   UIImageView *animatedIMvw = [[UIImageView alloc] init];
   animatedIMvw.animationImages = frames;
   [animatedIMvw startAnimating];
于 2012-06-21T09:56:09.043 回答
1

看看这个简单的例子:http ://appsamuck.com/day2.html

编辑

主页似乎坏了,所以请检查一下:

http://web.archive.org/web/20090207210729/http://appsamuck.com/day2.html

于 2012-06-21T09:54:33.093 回答