簡體   English   中英

SDWebImage動畫圖像

[英]SDWebImage animate images

我嘗試了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因為尚未加載圖像,所以method setImageWithURL:placeholderImage:completed:是一個異步函數。 您應該嘗試另一種方式: 在uiimageview中對圖像進行動畫處理

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM