2

我在一个包含许多不同 URL 的应用上有列表;因此,我将 info.plist 设置为 ...

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

在模拟器上一切正常。在我的测试设备上它不起作用。

错误是...

2015-11-10 18:58:05.159 MPSTApp [520:169178] -canOpenURL: URL 失败:“https:/www.facebook.com/prontosantateresa -- file:///” - 错误:“这个应用程序不是允许查询方案文件”

调用 url 链接的代码是这样的 -

var anchorLink: String?

func loadWebPage(){
    let requestURL = NSURL(string: anchorLink!)
    let request = NSURLRequest(URL: requestURL!)
    webView.loadRequest(request)
}
4

2 回答 2

1

您的网址中有错字。改变:

https:/facebook.com

至:

https://facebook.com

此外,您应该改LSAllowsArbitraryLoads回默认值,因为这对大多数应用程序来说是最好的。

于 2015-11-11T04:43:13.460 回答
0

对于 iOS9,您必须在 plist 文件中添加一些内容:

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>fbapi</string>
    <string>fbapi20130214</string>
    <string>fbapi20130410</string>
    <string>fbapi20130702</string>
    <string>fbapi20131010</string>
    <string>fbapi20131219</string>    
    <string>fbapi20140410</string>
    <string>fbapi20140116</string>
    <string>fbapi20150313</string>
    <string>fbapi20150629</string>
    <string>fbauth</string>
    <string>fbauth2</string>
    <string>fb-messenger-api20140430</string>
</array>

更多信息:为 iOS9 准备您的应用程序

于 2015-11-11T02:10:43.080 回答