2015-10-05 160 views
0

我在我的Swift 2.0項目中使用SDWebImage。當iOS上運行9總是返回以下錯誤SDWebImage總是返回錯誤代碼401

Error Domain=NSURLErrorDomain Code=401 "(null)" 

使用SDWebImage從服務器

cell.backgroundImageView.sd_setImageWithURL(NSURL(string: "http://..."), placeholderImage: placeholderImg, options: SDWebImageOptions.RetryFailed, completed: {(image, error, type, url) -> Void in 
    if error == nil { 
     // do something with image   
    } 
}) 

加載圖像由於這是一個http://請求,並在iOS上運行9,我也添加到我的Info.plist文件

<key>NSAppTransportSecurity</key> 
<dict> 
    <key>NSAllowsArbitraryLoads</key> 
    <true/> 
</dict> 

回答

0

原來,服務器需要身份驗證來請求此圖像資源。這就是爲什麼SDWebImage正確返回401錯誤代碼。

+0

這是[401](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html)http代碼是關於 –