ios - 如何安装 SDWebImage

标签 ios objective-c image-processing frameworks sdwebimage

我需要在我的应用程序中管理照片,并且阅读了很多关于 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 方法时,这些错误也会导致未找到错误。

这是我的项目的屏幕截图:

enter image description here

我希望我能得到一些帮助,因为该框架看起来具有非常好的功能。非常感谢任何帮助。谢谢

最佳答案

当您在项目中添加 SDWebImage 文件夹时,然后选择以下选项。将文件夹的副本添加到目标项目并创建组。

然后你必须这样写

#import "UIImageView+WebCache.h"

并确保您将添加到要使用该库的所有目标。

enter image description here

文档位于 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/

相关文章:

html - HTML 表格中的文本在 WKWebview 中是错误的可点击 "event"

php - 检测 "overall average"图片颜色

android - 如何在单个 ImageView 中获得不同的点击位置

iOS Swift 全局存储简单数据

ios - 是否可以在没有 GPS 跟踪的情况下发送 Twitter 自动回复?

iphone - NSAssert 在线程中的使用

ios - 使用缩写的月/日名称格式化 NSDate

iphone - 来自 iOS 5 中后台地理围栏的通知?

python - 删除视频帧的边框/边距

ios - 无法使用在线签名模式创建信封