我只想在网页浏览中加载此网址。当我在模拟器上运行相同的代码并且它在模拟器中正确加载时,它工作正常。当我在Real设备Iphone上运行代码时出错。我已经检查了许多例子没有解决。提前谢谢。
这是控制台日志
import UIKit
class ViewController: UIViewController, UIWebViewDelegate{
@IBOutlet weak var webViews: UIWebView!
override func viewDidLoad() {
super.viewDidLoad()
webViews.delegate = self
let url = NSURL (string: "http://myServerIP/FEXIGRA%20II/FEXIGRA%20II.html");
let requestObj = NSURLRequest(url: url! as URL);
do {
try webViews.loadRequest(requestObj as URLRequest)
} catch {
print(error.localizedDescription)
}
}
func webView(_ webView: UIWebView, didFailLoadWithError error: Error) {
print("Error is:\(error.localizedDescription)")
}
}
这是我的代码
{{1}}
答案 0 :(得分:0)
您是否将此添加到info.plist文件中?
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>