Created
November 22, 2020 06:50
-
-
Save growvv/ceac2f3492edc4fffe1d5f3f15c2bbbf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ViewController.swift | |
// ExampleUIWebView | |
// | |
// Created by admin on 2020/11/22. | |
// | |
import UIKit | |
import WebKit | |
class ViewController: UIViewController, WKUIDelegate { | |
var webView: WKWebView! | |
override func loadView() { | |
super.loadView() | |
let webConfiguration = WKWebViewConfiguration() | |
webView = WKWebView(frame: .zero, configuration: webConfiguration) | |
webView.uiDelegate = self | |
view = webView | |
} | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
// Do any additional setup after loading the view. | |
let myURL = URL(string: "https://apple.com") | |
let myRequest = URLRequest(url: myURL!) | |
webView.load(myRequest) | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
使用WKWebView代替UIWebView
ref: https://developer.apple.com/documentation/webkit/wkwebview