ios - SDWebImage 找不到 SDImageCacheType

标签 ios objective-c swift sdwebimage

我面临的问题是无法使用SDWebImage库(用Objective-C编写)的完成 block 。我在多个地方使用 sd_setImageWithURL,但每次收到错误使用未声明的类型“SDImageCacheType”。该问题出现在 2 台不同的 MacBook 上。我检查了一下,缺少的类型在 SDWebImage.h 文件中声明(附在最后)。我正在使用 CocoaPods。

How it looks on XCode

基本源代码

        imageViewMain.sd_setImageWithURL(NSURL(string: finalURL)) //Works fine

        // Doesn't work.
        let b : SDImageCacheType = SDImageCacheType.None
        let block = {(image: UIImage!, error: NSError!, cacheType: SDImageCacheType.None, imageURL: NSURL!) -> Void in
            println(self)
        }
        imageViewMain.sd_setImageWithURL(NSURL(string: finalURL), completed: block)

桥接 header 基本行

#import <SDWebImage/SDImageCache.h>

SDImageCache.h 文件顶部

/*
 * This file is part of the SDWebImage package.
 * (c) Olivier Poitrey <<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="fd8f8ebd999c949184909289949293d39e9290" rel="noreferrer noopener nofollow">[email protected]</a>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

#import <Foundation/Foundation.h>
#import "SDWebImageCompat.h"
typedef NS_ENUM(NSInteger, SDImageCacheType) {
    /**
     * The image wasn't available the SDWebImage caches, but was downloaded from the web.
     */
    SDImageCacheTypeNone,
    /**
     * The image was obtained from the disk cache.
     */
    SDImageCacheTypeDisk,
    /**
     * The image was obtained from the memory cache.
     */
    SDImageCacheTypeMemory
};

Podfile

pod 'SDWebImage's'
use_frameworks!

最佳答案

好吧,这是一个非常微不足道的问题,我不知道为什么我没有早点弄清楚。我需要做的就是添加一个导入。看起来如果您使用声明的 block ,您需要添加它。

import SDWebImage  

关于ios - SDWebImage 找不到 SDImageCacheType,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32483112/

相关文章:

iphone - UITextField 的自定义字体在编辑模式下发生变化

ios - Swift import 语句失败

ios - 尝试使用 Swift 制作一个基本的贪吃蛇游戏

ios - iOS/iPhone 应用程序的(文件)格式是什么?

ios - 在 Swift 中使用 Hello World 程序的“NSInvalidArgumentException”

ios - 在 Xcode 中使用带有可重用单元格的按钮和 TextFields

ios - 在 UIScrollview 中有一个 UITextView 有什么意义?

ios - 变量已设置但打印出 nil

swift - 如何知道多个网络调用何时结束,调用完成

ios - 将图像添加到 UIView 的绘图中而不让图像扩散