iOS9—xcode7常見錯誤https問題解決

來源:互聯網
上載者:User

iOS9—xcode7常見錯誤https問題解決
遇到的錯誤

The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.

少年莫慌,這是升級的ios9的https問題,解決起來很簡單,關閉他,咱還是用http

解決

1:在Info.plist中添加NSAppTransportSecurity類型Dictionary。
2:在NSAppTransportSecurity下添加NSAllowsArbitraryLoads類型Boolean,值設為YES
3:注意,單元測試下面也有一個Info.plist,修改那個檔案是沒有作用的!

其他

如果想讓有的網域名稱支援https的話也可以這麼配置:
補充了配置的方法
對於實在不支援HTTPS的應該首先考慮添加例外

添加例外的方式也很簡單:
左鍵Info.plist選擇open with source code
然後添加類似如下的配置:

    NSAppTransportSecurity            NSExceptionDomains                    qq.com                            NSIncludesSubdomains                                        sina.com.cn                            NSIncludesSubdomains                                          

根據自己需要的網域名稱修改, NSIncludeSubdomains 顧名思義是包括子域的意思。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.