Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/103.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/5/objective-c/27.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
如何使用SDWebImage在iOS中设置渐进式图像?_Ios_Objective C_Sdwebimage - Fatal编程技术网

如何使用SDWebImage在iOS中设置渐进式图像?

如何使用SDWebImage在iOS中设置渐进式图像?,ios,objective-c,sdwebimage,Ios,Objective C,Sdwebimage,我尝试在我的应用程序中逐步加载图像。基本上我尝试的是当图像加载时,我想显示从模糊状态完全加载的图像。我试过了 SDWebImageManager *manager = [SDWebImageManager sharedManager]; [manager downloadImageWithURL:[NSURL URLWithString:@"https://profile.microsoft.com/RegsysProfileCenter/Images/personal_info.jpg"]

我尝试在我的应用程序中逐步加载图像。基本上我尝试的是当图像加载时,我想显示从模糊状态完全加载的图像。我试过了

SDWebImageManager *manager = [SDWebImageManager sharedManager];
[manager downloadImageWithURL:[NSURL URLWithString:@"https://profile.microsoft.com/RegsysProfileCenter/Images/personal_info.jpg"]
                      options:0
                     progress:^(NSInteger receivedSize, NSInteger expectedSize) {
                         [self.profileBtn setImage:[UIImage imageWithData:[NSData dataWithBytes:&receivedSize length:sizeof(receivedSize)] scale:15] forState:UIControlStateNormal];
                     }
                    completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
                        if (image) {
                            // [self.profileBtn setImage:image forState:UIControlStateNormal];
                        }
                    }];

是否可以使用SDWebImage逐步加载图像。请帮我解决这个问题。

您可以在临时标签上或活动指示灯下显示下载百分比(可以在图像视图或按钮上显示活动指示灯,直到下载未完成),如进行中块

 NSInteger downloadCompleted = (receivedSize/ expectedSize) * 100;
 label.text = downloadCompleted; //temp label on image view or below activityindicator

希望这会有所帮助:)

您可以在临时标签上或活动指示灯下显示下载百分比(可以在图像视图或按钮上显示活动指示灯,直到下载未完成),如进行中块

 NSInteger downloadCompleted = (receivedSize/ expectedSize) * 100;
 label.text = downloadCompleted; //temp label on image view or below activityindicator

希望这会有所帮助:)

您可以尝试此实现

+ (void)loadImageWithURLString:(NSString *)urlString forImageView:(UIImageView *)imageView {
    [imageView sd_setImageWithURL:[Utilities stringToURL:urlString]
                 placeholderImage:[UIImage placeHolderImage]
                          options:SDWebImageProgressiveDownload];
}
这个选项说

/**
     * This flag enables progressive download, the image is displayed progressively during download as a browser would do.
     * By default, the image is only displayed once completely downloaded.
     */
    SDWebImageProgressiveDownload = 1 << 3,
/**
*此标志启用渐进式下载,图像在下载过程中会像浏览器一样渐进式显示。
*默认情况下,图像仅在完全下载后显示。
*/

SDWebImageProgressiveDownload=1您可以尝试此实现

+ (void)loadImageWithURLString:(NSString *)urlString forImageView:(UIImageView *)imageView {
    [imageView sd_setImageWithURL:[Utilities stringToURL:urlString]
                 placeholderImage:[UIImage placeHolderImage]
                          options:SDWebImageProgressiveDownload];
}
这个选项说

/**
     * This flag enables progressive download, the image is displayed progressively during download as a browser would do.
     * By default, the image is only displayed once completely downloaded.
     */
    SDWebImageProgressiveDownload = 1 << 3,
/**
*此标志启用渐进式下载,图像在下载过程中会像浏览器一样渐进式显示。
*默认情况下,图像仅在完全下载后显示。
*/

SDWebImageProgressiveDownload=1您有可以快速下载的thumb URL吗。在这种情况下,您可以显示拇指图像,直到未下载大图像。我曾经遇到过同样的情况,我用拇指图像url解决了这个问题。否则,使用进度条是唯一的选择。查看此链接后,您可以按照此链接获得答案:您是否有可以快速下载的拇指URL。在这种情况下,您可以显示拇指图像,直到未下载大图像。我曾经遇到过同样的情况,我用拇指图像url解决了这个问题。否则,使用进度条是唯一的选项。查看此链接后,您可以按照此链接获得答案:注意,这要求使用渐进式JPEG压缩保存文件。如果要显示模糊状态的图像,我认为一种可能的解决方案是在占位符图像上创建一个模糊层,模糊值由下载完成的百分比设置。请注意,这要求使用渐进式JPEG压缩保存文件。如果要显示处于模糊状态的图像,我认为一个可能的解决方案是在占位符图像上创建一个模糊层,模糊值由下载完成的百分比设置。