2017-07-16 68 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开发人员。 –