如何使用 NSUrl 数组而不是 UIImage 数组为 UIImageView 设置动画?
How to animate a UIImageView with array of NSUrl intead array of UIImage?
在我的应用程序中,我使用的是 SDWebImageView,我必须在 table 中显示用户列表,每个用户都有 6 张图像。所以我必须展示每张图片。
我正在使用以下代码在屏幕上制作动画图像。
[smallDpImageV setImage:[UIImage animatedImageWithImages:_dynamicImageArray duration:time]];
[smallDpImageV startAnimating];
它接收一个 uiimage 数组,这里每个图像都是由 URL 创建的。但是对于 tableview,我不想在 uiimage 上创建多个数组。
我可以用 NSUrl 做吗?像这样
[imgV sd_setImageWithURL:[dict valueForKey:@"thumb_nail"] placeholderImage:[UIImage imageNamed:@"1447851886_male3.png"]];
我在 SDWebImageView 中找到了答案。
for (NSDictionary *dict in [mainDict valueForKey:@"profile_pic"]) {
[imgArr addObject:[NSURL URLWithString:[NSString stringWithFormat:@"%@",[dict valueForKey:@"thumb_nail"]]]];
}
if (imgArr.count >0) {
[cell.imgViewUserImage sd_setAnimationImagesWithURLs:imgArr];
cell.imgViewUserImage.animationDuration = imgArr.count*2;
[cell.imgViewUserImage startAnimating];
}
在我的应用程序中,我使用的是 SDWebImageView,我必须在 table 中显示用户列表,每个用户都有 6 张图像。所以我必须展示每张图片。 我正在使用以下代码在屏幕上制作动画图像。
[smallDpImageV setImage:[UIImage animatedImageWithImages:_dynamicImageArray duration:time]];
[smallDpImageV startAnimating];
它接收一个 uiimage 数组,这里每个图像都是由 URL 创建的。但是对于 tableview,我不想在 uiimage 上创建多个数组。
我可以用 NSUrl 做吗?像这样
[imgV sd_setImageWithURL:[dict valueForKey:@"thumb_nail"] placeholderImage:[UIImage imageNamed:@"1447851886_male3.png"]];
我在 SDWebImageView 中找到了答案。
for (NSDictionary *dict in [mainDict valueForKey:@"profile_pic"]) {
[imgArr addObject:[NSURL URLWithString:[NSString stringWithFormat:@"%@",[dict valueForKey:@"thumb_nail"]]]];
}
if (imgArr.count >0) {
[cell.imgViewUserImage sd_setAnimationImagesWithURLs:imgArr];
cell.imgViewUserImage.animationDuration = imgArr.count*2;
[cell.imgViewUserImage startAnimating];
}