今天在学习IOS的WebView控件时发现WebView加载URL报错,菜鸟的我只能上Google一查究竟。
错误信息:
The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.
最后网上查到在IOS9的时候引入了App Transport Security (ATS)。
详细文档参考:https://developer.apple.com/library/prerelease/ios/releasenotes/General/WhatsNewIniOS/Articles/iOS9.html#//apple_ref/doc/uid/TP40016198-DontLinkElementID_13
解决办法:
第一步:在Info.plist中添加NSAppTransportSecurity类型Dictionary。
第二步:在NSAppTransportSecurity下添加NSAllowsArbitraryLoads类型Boolean,值为YES。