iOS9要求App內訪問的網絡必須使用HTTPS協議。原有的HTTP請求會報錯,適配方法以下。網絡
打開TARGETS-Build Phases, 添加New Run Script Phase,代碼以下:post
# Add exception for Debug builds if [ "${CONFIGURATION}" == "Debug" ] then # Remove exception existing builds /usr/libexec/PlistBuddy -c "Delete :NSAppTransportSecurity:NSAllowsArbitraryLoads" "${CONFIGURATION_BUILD_DIR}/${INFOPLIST_PATH}" exitCode=$? #Supresses failure /usr/libexec/PlistBuddy -c "Add :NSAppTransportSecurity:NSAllowsArbitraryLoads bool true" "${CONFIGURATION_BUILD_DIR}/${INFOPLIST_PATH}" fi
其中"${CONFIGURATION}" == "Debug"的Debug替換爲相應編譯環境便可ui