主要目的是稍后在加载期间不设置图像.
谢谢
解决方法 来自SDWeb Image Documentation:Using blocks
With blocks,you can be notifIEd about the image download progress and
whenever the image retrIEval has completed with success or not:
// Here we use the new provIDed sd_setimageWithURL: method to load the web image
对于Swift:
cell.imageVIEw.sd_setimageWithURL(url,placeholderImage:nil,completed: { (image,error,cacheType,url) -> VoID in if (error) { // set the placeholder image here } else { // success ... use the image } })
对于Objective-C
[cell.imageVIEw sd_setimageWithURL:[NSURL URLWithString:@"http://www.domain.com/path/to/image.jpg"] placeholderImage:nil completed:^(UIImage *image,NSError *error,SDImageCacheType cacheType,NSURL *imageURL) { if (error) { self.imageVIEw.image = [UIImage imagenamed:@"placeHolderImage"]; } }];总结
以上是内存溢出为你收集整理的ios – 仅当图像无法加载SDWebImage时才设置占位符图像全部内容,希望文章能够帮你解决ios – 仅当图像无法加载SDWebImage时才设置占位符图像所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)