Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/115.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios SDWebImage为图像设置动画_Ios_Animation_Uiimageview_Nsarray_Sdwebimage - Fatal编程技术网

Ios SDWebImage为图像设置动画

Ios SDWebImage为图像设置动画,ios,animation,uiimageview,nsarray,sdwebimage,Ios,Animation,Uiimageview,Nsarray,Sdwebimage,我尝试了100多种使用SDWebImage制作图像动画的方法,但总是失败。我了解使用积木的好处吗?我有IBOutlet属性映像名称images1。我制作了一个数组来存储值并设置3幅图像的动画 NSMutableArray *imagegallery = [[NSMutableArray alloc] init]; NSLog(@"IMAGES-%@", imagegallery); [self.images1 setImageWithURL:[N

我尝试了100多种使用SDWebImage制作图像动画的方法,但总是失败。我了解使用积木的好处吗?我有IBOutlet属性映像名称images1。我制作了一个数组来存储值并设置3幅图像的动画

  NSMutableArray *imagegallery = [[NSMutableArray alloc] init];

        NSLog(@"IMAGES-%@", imagegallery);


            [self.images1 setImageWithURL:[NSURL URLWithString:[self.objc objectForKey:@"Img1"]]
                         placeholderImage:[UIImage imageNamed:@"placeholder.png"]
                                completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType) {

                                    [imagegallery addObject:image];
                                    NSLog(@"Ima1-------%@", image);
                                }];
            [self.images1 setImageWithURL:[NSURL URLWithString:[self.objc objectForKey:@"Img2"]]
                         placeholderImage:[UIImage imageNamed:@"placeholder.png"]
                                completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType) {
                                    [imagegallery addObject:image];
                                }];
            [self.images1 setImageWithURL:[NSURL URLWithString:[self.objc objectForKey:@"Img3"]]
                         placeholderImage:[UIImage imageNamed:@"placeholder.png"]
                                completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType) {
                                    [imagegallery addObject:image];
                                }];

        self.images1.animationImages = imagegallery; //this line gets error
        self.images1.animationDuration = 0.5;
        [self.view addSubview:self.images1];
        [self.images1 startAnimating];

问题在于imageGallery包含字符串以及添加到已完成块中的图像。首先没有理由将imageGallery设置为animatee的副本,因为您从未在imageGallery中使用这些字符串。只需为imageGallery创建一个新的空可变数组。

我认为当您设置
self.images1.animationImages=imageGallery
时,由于您的图像尚未加载,
方法setImageWithURL:Placeholder图像:completed:
是一个异步函数。你应该试试别的办法 比如:

您得到了什么错误?-[\uu NSCFConstantString\u isResizable]:无法识别的选择器发送到了实例0x2fce30(lldb)。无论如何,如果我使用空可变数组(如编辑问题)执行此操作,它不会显示任何图像。如果我在NSMutableArray中添加更多的SdWebImage,对所有这些都使用我的名为images1的IBOutlet属性可以吗?@Milan1111,我认为使用setImageWithURL下载一系列图像并不是一个真正正确的方法,因为它设置了图像视图的图像--通过连续调用3次,你将图像更改了三次,这真的没有意义。我认为您不会得到任何图像,因为下载方法是异步的,并且self.images1.animationImages=image gallery行在图像返回之前正在运行。我还没有用过SDWebImage,所以我不知道用什么方法更合适。无论如何,谢谢你的帮助,如何思考。是的,它很有效,谢谢。无论如何,我需要大约2-3秒的时间才能移动到带有图像的ViewController,而不使用异步功能。你以前使用过这个方法吗?我认为不应该使用imageUrl来制作动画图像,相反,你可以加载一个gif图像url并设置为你的imageView。