
这是我的代码 –
-(voID)setimageWithUrl:(NSURL*)imgurl onImageVIEw:(UIImageVIEw*)image prograssive:(BOol)progressive{ __block UIActivityIndicatorVIEw *activityIndicator; __weak UIImageVIEw *weakImageVIEw = image; SDWebImageOptions opt; if (progressive) { opt = SDWebImageProgressiveDownload; } else opt = SDWebImageRetryFailed; [image sd_setimageWithURL:imgurl placeholderImage:[UIImage imagenamed:@"default_image"] options:opt progress:^(NSInteger receivedSize,NSInteger expectedSize) { if (!activityIndicator) { [weakImageVIEw addSubvIEw:activityIndicator = [UIActivityIndicatorVIEw.alloc initWithActivityIndicatorStyle:UIActivityIndicatorVIEwStyleGray]]; activityIndicator.center = CGPointMake(weakImageVIEw.frame.size.wIDth /2,weakImageVIEw.frame.size.height/2); // activityIndicator.center = weakImageVIEw.center; [activityIndicator setBackgroundcolor:[UIcolor clearcolor]]; [activityIndicator startAnimating]; } } completed:^(UIImage *image,NSError *error,SDImageCacheType cacheType,NSURL *imageURL) { [activityIndicator removeFromSupervIEw]; activityIndicator = nil; }];} 在AppDelegate-
- (voID)applicationDIDReceiveMemoryWarning:(UIApplication *)application{ [[SDImageCache sharedImageCache] clearMemory]; [[SDImageCache sharedImageCache] cleandisk]; [[SDImageCache sharedImageCache] cleardisk]; [[SDImageCache sharedImageCache] setValue:nil forKey:@"memCache"];} 请不要图像是高分辨率(超过3000像素宽度).例如其中一个有4256 * 2832和979KB大小产生内存警告.任何帮助或建议将不胜感激.
编辑: – 我的应用程序因内存压力而被杀,但仅限于iPhone 4s及更低版本(在iPhone5及更高版本上工作正常).当下载大型图像(或完整下载)时,我突然出现内存峰值(它从〜约25mb到~90mb)和应用程序崩溃.任何建议怎么办?
以上是内存溢出为你收集整理的ios – 使用SDWebImage下载大图像时应用程序崩溃?全部内容,希望文章能够帮你解决ios – 使用SDWebImage下载大图像时应用程序崩溃?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)