How to integrate latest SDWebImage API in my Swift based project?

前端 未结 3 465
清歌不尽
清歌不尽 2021-01-04 10:46

I have used SDWebImage with Objective C and it worked great for me but now I am learning Swift and trying to integrate the latest version of the API but I am stucking at eve

3条回答
  •  甜味超标
    2021-01-04 11:32

    Here is a code example that should work :

    let block: SDWebImageCompletionBlock! = {(image: UIImage!, error: NSError!, cacheType: SDImageCacheType!, imageURL: NSURL!) -> Void in
        println(self)
    }
    
    let url = NSURL(string: "http://placehold.it/350x150")
    
    self.imageView.sd_setImageWithURL(url, completed: block)
    

    and in your bridging header file :

    #import "UIImageView+WebCache.h"
    

    So your bridging header file should work, but sometimes I had trouble with the bridging header and in theses cases I just delete it, and add it again and everything works fine after.

提交回复
热议问题