가장 좋은 방법은 SDWebImage 폴더를 프로젝트로 드래그 앤 드롭하는 것입니다. '필요한 경우 항목 복사'에 체크 표시가되어 있는지 확인하십시오.
Obj C 브리징 만들기 : 파일 -> 새로 만들기 -> 소스 -> 헤더 파일 -> AppName-Bridging-Header로 이름.
추가 다음 https://developer.apple.com/library/ios/documentation/Swift/Conceptual/BuildingCocoaApps/MixandMatch.html
참고 : 참고
#ifndef AppName_AppName_Bridging_Header_h
#define AppName_AppName_Bridging_Header_h
#import <SDWebImage/UIImageView+WebCache.h>
#import "UIImageView+WebCache.h"
#endif
or
#import "UIImageView+WebCache.h"
스위프트 컴파일러에서 빌드 설정 - 코드 생성 확인 오브젝티브 C 브리징 헤더에서 설정을 구축 할 수 있도록이 경로를 가지고 브리징 헤더 파일. - 그 testSD/testSD-브리징 - header.h가 또는 testSD-브리징 - header.h가 (헤더 파일 경로를 프로젝트 폴더를 열고 찾기)
지금이 코드를 시도 같은 :
let block: SDWebImageCompletionBlock! = {(image: UIImage!, error: NSError!, cacheType: SDImageCacheType!, imageURL: NSURL!) -> Void in
println(self)
}
let url = NSURL(string: "http://arrow_upward.com/350x150")
self.imageView.sd_setImageWithURL(url, completed: block)
가정하자 UICollectionView를 사용하여 캐시 이미징을 채우는 경우이 코드를 사용해보십시오.
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = photoListCollectionView.dequeueReusableCellWithReuseIdentifier("scoutimagecellidentifier", forIndexPath: indexPath) as! ScoutImageCell
//Loading image from server using SDWebImage library
let thumbImageUrl = NSURL(string: self.photoPropertyArray[indexPath.row] as String)
//Image Fetching is done in background GCD thread
SDWebImageManager.sharedManager().downloadImageWithURL(thumbImageUrl, options: [],progress: nil, completed: {[weak self] (image, error, cached, finished, url) in
if let wSelf = self {
//On Main Thread
dispatch_async(dispatch_get_main_queue()){
cell.scoutimage.image = image
cell.photoloader.stopAnimating()
}
}
})
return cell
}
http://stackoverflow.com/questions/24948480/sdwebimage-crash-in-swift –
더 나은 서비스를 신속한 이미지 캐싱에 Haneke 사용 https://github.com/Haneke/HanekeSwift –
@Saurabh Prajapati : 이것을 사용 했습니까? 어때? – Developer