gpt4 book ai didi

iphone - 如何在 ios 4 中以编程方式将图像数组添加到 Imageview?

转载 作者:可可西里 更新时间:2023-11-01 04:23:57 25 4
gpt4 key购买 nike

我需要在单个 View 中显示图像数组,这些图像在 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];

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

最佳答案

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


改用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 documentation ;

animationImages

用于动画的 UIImage 对象数组。

@property(nonatomic, copy) NSArray *animationImages

Discussion The array must contain UIImage objects. You may use the same image object more than once in the array. Setting this property to a value other than nil hides the image represented by the image property. The value of this property is nil by default.

可用性适用于 iOS 2.0 及更高版本。也可以看看 @属性(property)形象 @property 内容模式 (UIView)声明于UIImageView.h

关于iphone - 如何在 ios 4 中以编程方式将图像数组添加到 Imageview?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11135583/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com