我需要在我的应用程序中管理照片,并且阅读了很多关于 SDWebImage 框架的内容,这似乎是最好的方法。 但是我发现安装起来非常困难。我不知道 Ruby,也从未使用过 podfile,所以我通过下载最新的 SDWebImagefolder 和框架并将它们添加到我的项目中来安装它。但是,当我尝试使用建议的导入导入我的 View Controller 时:
#import <SDWebImage/UIImageView+WebCache.h>
#import "UIImageView+WebCache.h"
我在#import 上找不到文件,然后如果我按照建议将其更改为“SDWebImage/UIImageView+WebCache.h”,我会在#import UIImageView+WebCache.h 上找不到文件,即使我打开我项目中的SDWebImage文件夹就可以清楚的看到了!我猜测当我尝试使用 sd_setImageWithUrl 方法时,这些错误也会导致未找到错误。
这是我的项目的屏幕截图:
我希望我能得到一些帮助,因为该框架看起来具有非常好的功能。非常感谢任何帮助。谢谢
最佳答案
当您在项目中添加 SDWebImage
文件夹时,然后选择以下选项。将文件夹的副本添加到目标项目并创建组。
然后你必须这样写
#import "UIImageView+WebCache.h"
并确保您将添加到要使用该库的所有目标。
文档位于 Github :
Add the SDWebImage project to your project
- Download and unzip the last version of the framework from the download page
- Right-click on the project navigator and select "Add Files to "Your Project":
- In the dialog, select SDWebImage.framework:
- Check the "Copy items into destination group's folder (if needed)" checkbox
或者您可以使用 cocoa pods
作为其他建议的答案。
编辑:示例:
[self.imageView sd_setImageWithURL:[NSURL URLWithString:"yoururl.png"] placeholderImage:[UIImage imageNamed:@"placeholder.png"]];
关于ios - 如何安装 SDWebImage,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32303778/