Skip to content

Instantly share code, notes, and snippets.

@akio0911
Created November 26, 2020 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akio0911/8f50f46b25d91e1e291905946dc9aad3 to your computer and use it in GitHub Desktop.
Save akio0911/8f50f46b25d91e1e291905946dc9aad3 to your computer and use it in GitHub Desktop.
import UIKit
import SafariServices
import WebKit
class ViewController: UIViewController {
@IBOutlet weak var webView: WKWebView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
@IBAction func openSafari(_ sender: Any) {
let url = URL(string: "https://yahoo.co.jp")!
UIApplication.shared.open(url, options: [:], completionHandler: nil)
}
@IBAction func presentSafariViewController(_ sender: Any) {
let url = URL(string: "https://yahoo.co.jp")!
let safari = SFSafariViewController(url: url)
present(safari, animated: true, completion: nil)
}
@IBAction func loadWebView(_ sender: Any) {
let url = URL(string: "https://yahoo.co.jp")!
let request = URLRequest(url: url)
webView.load(request)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment