2017-07-16 75 views
0

在我的應用程序後,我想顯示的Twitter用戶的個人資料圖片,但Twitter提供通過HTTP鏈接:無法加載基於HTTP的圖像,即使添加例外

http://pbs.twimg.com/profile_images/843199968018157568/zHovYMDk_normal.jpg

我已經更新了我的info.plist以包括Twitter用於其個人資料圖片的域名:

<key>NSAppTransportSecurity</key> 
<dict> 
    <key>NSExceptionDomains</key> 
    <dict> 
     <key>localhost</key> 
     <dict> 
      <key>NSExceptionAllowsInsecureHTTPLoads</key> 
      <true/> 
     </dict> 
     <key>pbs.twimg.com</key> 
     <dict> 
      <key>NSExceptionAllowsInsecureHTTPLoads</key> 
      <true/> 
      <key>NSIncludesSubdomains</key> 
      <true/> 
     </dict> 
    </dict> 
</dict> 

但是我仍然無法加載圖像。我也試過NSAllowsArbitraryLoads,但那也沒用。

我哪裏錯了?

+0

將您的代碼粘貼到您使用該網址的位置。您是否從控制檯收到有關傳輸安全的任何消息? –

回答

1

如果check the documentation你會看到圖片鏈接以https鏈接返回:

... 
"profile_image_url": "http://pbs.twimg.com/profile_images/530814764687949824/npQQVkq8_normal.png", 
"profile_image_url_https": "https://pbs.twimg.com/profile_images/530814764687949824/npQQVkq8_normal.png", 
... 

所以從profile_image_url_https使用的值,你應該罰款。

+0

謝謝特倫斯,不敢相信我錯過了!你知道爲什麼我的info.plist中的異常不起作用嗎? – JmJ

+1

對不起JmJ - 我不是iOS開發人員。 –