So I just updated to the new Xcode8
and Swift3
but now my web view does not work. Here is the code I used:
UIWebView.loadRequest(webVie
'UIWebView' was deprecated in iOS 12.0: No longer supported; please adopt WKWebView.
WKWebView Sample
ViewController.swift
import UIKit
class ViewController: UIViewController, UIWebViewDelegate {
@IBOutlet weak var webView: UIWebView!
override func viewDidLoad() {
super.viewDidLoad()
webView.delegate = self
if let url = URL(string: "http://apple.com") {
let request = URLRequest(url: url)
webView.loadRequest(request)
}
}
}
Main.storyboard
import UIKit
class ViewController: UIViewController, UIWebViewDelegate {
var webView: UIWebView!
override func viewDidLoad() {
super.viewDidLoad()
webView = UIWebView(frame: UIScreen.main.bounds)
webView.delegate = self
view.addSubview(webView)
if let url = URL(string: "http://apple.com") {
let request = URLRequest(url: url)
webView.loadRequest(request)
}
}
}
Info.plist
add in your Info.plist transport security setting
NSAppTransportSecurity
NSAllowsArbitraryLoads
WKWebView Sample