繁体   English   中英

下载图像时出现内存警告和应用程序崩溃

[英]Memory warning and app crash when downloading images

我正在使用SDWebImage库,图像约为0.5 MB,并在单击UITableViewCell时在detailView显示。

详细视图中的代码:

- (void)configureView
{
    if (self.imageURL)
    {
        [self.imageView setImageWithURL:self.imageURL placeholderImage:nil options:SDWebImageProgressiveDownload progress:^(NSUInteger receivedSize, long long expectedSize)
         {
             float percentDone = (float)receivedSize*200/(receivedSize+expectedSize);
             [SVProgressHUD showWithStatus:[NSString stringWithFormat:@"Downloading... %0.0f%%", percentDone]];
             if (percentDone == 100) {
                 [SVProgressHUD showSuccessWithStatus:@"Loaded."];
             }
         }
                              completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType)
         {

         }];
    }
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self configureView];
}

图像太大(半兆字节)吗? SDWebImage缓存这些图像。

您说您在viewDidUnload中释放了imageView.image,但在ios6上不推荐使用viewDidUnload。 视图不再被卸载..该方法可能不被调用:)

didReceiveMemoryWarning

在TABLEViewCell中使用SDWebImageProgressiveDownload不是一个好主意,使用SDWebImageRetryFailed会很好

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM