Updated for Swift 3:
If you want to close the UIWebView page and return to the application, use the code below:
import UIKit class ViewController: UIViewController, UIWebViewDelegate{ @IBOutlet weak var mWebView: UIWebView! override func viewDidLoad() { super.viewDidLoad() mWebView.delegate = self } override func viewWillAppear(_ animated: Bool) { self.loadWebView() } func loadWebView() { mWebView.loadRequest(URLRequest(url: URL(string: "https://stackoverflow.com/")!)) } func webView(_ webView: UIWebView, shouldStartLoadWith request: URLRequest, navigationType: UIWebViewNavigationType) -> Bool { print("request: \(request.description)") if request.description == "https://stackoverflow.com/users/login"{
source share