這兩天研究SDWebimage庫,在xode 7上運行過程當中遇到了些問題,建立的新項目因爲使用到了https的圖片URL,運行後,怎麼都不出現圖片,發送請求時,報下面的錯: 緩存
「App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app’s Info.plist file」網絡
通過搜索stackoverflow查詢相關問題發現,iOS9新特性要求App內訪問網絡請求要採用HTTPS協議,不管url是http的仍是https的。經過進行以下設置便可:app
|
而後嘗試了SDWebimage不一樣的圖片加載方法,均成功展現。後面能夠正常研究圖片緩存的實現了。url
/**spa * Using SDWebimagecode */blog NSURL *imgURL = [NSURL URLWithString:@"http://www.sogou.com/images/logo/new/sogou.png"];圖片
// Using UIImageView+WebCache categoryget [imageView sd_setImageWithURL:imgURLit placeholderImage:[UIImage imageNamed:@"default_pic"]];
// Using blocks [imageView sd_setImageWithURL:imgURL placeholderImage:[UIImage imageNamed:@"default_pic"] completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
}];
// Using SDWebImageManager SDWebImageManager *manager = [SDWebImageManager sharedManager]; [manager downloadImageWithURL:imgURL options:0 progress:^(NSInteger receivedSize, NSInteger expectedSize) { // progression tracking code } completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) { if (image) { // do something with image [imageView setImage:image]; } }];
// Using Asynchronous Image Downloader Independently SDWebImageDownloader *downloader = [SDWebImageDownloader sharedDownloader]; [downloader downloadImageWithURL:imgURL options:0 progress:^(NSInteger receivedSize, NSInteger expectedSize) { // progression tracking code } completed:^(UIImage *image, NSData *data, NSError *error, BOOL finished) { if (image && finished) { // do something with image [imageView setImage:image]; } }]; |