Limit WebView to One URL

Hello. I am making an app that has a web view in it. I have opened a thread before about something like this, but I wasn't so clear on what I am trying to do, so I want to give it another shot.


I am very, very, very new to coding, so please talk to me like you are talking to a 2-year-old. 🙂 Anyways, so I have this app that has a webview in it, but, I want the webview to be limited to only ONE website. For example, let's just say it's apple.com. What I want is where if a user clicks on a link in that webview, I want that website to open in the Safari app, not the webview. I want to use a UIWebView if possible, and I want it to be as simple as possible.😁


Here's the code...


import UIKit
class ViewController: UIViewController, {
  
    @IBOutlet var webView: UIWebView!

    override func viewDidLoad() {
        super.viewDidLoad()
        /
      
        var URL = NSURL(string: "http:/apple.com"
      
        webView.loadRequest(NSURLRequest(url: URL! as URL) as URLRequest)
      
      
    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        
    }



Thanks so much for the help! You don't know how much this means to me!



This app is created with Swift 3 and Xcode 8

Replies

>I want to use a UIWebView if possible

>This app is created with Swift 3 and Xcode 8


Just to note that in that case, you should work with WKWebView, I think, so have to ask why you want UIWebView, instead?