ios开发中,由于安全原因,系统会拦截http请求(android开发中也会有这个问题,解决方式相对容易,系统提示比较好)。解决的方法之一是在info.plist中右键选择open as -> source code方式打开文件,在<dict>下添加以下语句:
swift中
<key>AppTransportSecurity</key>
<dict>
<key>AllowsArbitraryLoads</key>
<true/>
</dict>
oc中
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
具体如下: