Created
November 26, 2020 14:23
-
-
Save akio0911/8f50f46b25d91e1e291905946dc9aad3 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
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