美文网首页
解决项目不能加载网络的问题--老镇豆瓣电台学习总结

解决项目不能加载网络的问题--老镇豆瓣电台学习总结

作者: Dominic1992 | 来源:发表于2016-01-11 20:24 被阅读151次

    不知道从Xcode哪个版本开始,创建后的项目就不能进行网络数据的加载了.
    如果要进行网络加载,需要修改info.plist文件.
    1.右键info.plist
    2.Open As -> Source Code
    3.在源码中添加以下代码即可

        <key>NSAppTransportSecurity</key>
        <dict>
            <key>NSAllowsArbitraryLoads</key>
            <true/>
        </dict>
    

    此时切换回Property List就回发现多了App Transport Security Settings

    plist.png

    我的info.plist文件源码如下,我把上面的代码添加到了最后

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
        <key>CFBundleDevelopmentRegion</key>
        <string>en</string>
        <key>CFBundleExecutable</key>
        <string>$(EXECUTABLE_NAME)</string>
        <key>CFBundleIdentifier</key>
        <string>eko.hcxy.me.$(PRODUCT_NAME:rfc1034identifier)</string>
        <key>CFBundleInfoDictionaryVersion</key>
        <string>6.0</string>
        <key>CFBundleName</key>
        <string>$(PRODUCT_NAME)</string>
        <key>CFBundlePackageType</key>
        <string>APPL</string>
        <key>CFBundleShortVersionString</key>
        <string>1.0</string>
        <key>CFBundleSignature</key>
        <string>????</string>
        <key>CFBundleVersion</key>
        <string>1</string>
        <key>LSRequiresIPhoneOS</key>
        <true/>
        <key>UILaunchStoryboardName</key>
        <string>LaunchScreen</string>
        <key>UIMainStoryboardFile</key>
        <string>Main</string>
        <key>UIRequiredDeviceCapabilities</key>
        <array>
            <string>armv7</string>
        </array>
        <key>UISupportedInterfaceOrientations</key>
        <array>
            <string>UIInterfaceOrientationPortrait</string>
            <string>UIInterfaceOrientationLandscapeLeft</string>
            <string>UIInterfaceOrientationLandscapeRight</string>
        </array>
        <key>NSAppTransportSecurity</key>
        <dict>
            <key>NSAllowsArbitraryLoads</key>
            <true/>
        </dict>
    </dict>
    </plist>
    

    相关文章

      网友评论

          本文标题:解决项目不能加载网络的问题--老镇豆瓣电台学习总结

          本文链接:https://www.haomeiwen.com/subject/looqkttx.html