Mike Mike - 1 year ago 65
Swift Question

how to put web browser into an ios app?

I need to put web browser into my ios app (I use Swift). How can I add that? Thanks!

Answer Source
  1. Drag webview inside your viewcontroller from the object library
  2. Set outlet: @IBOutlet weak var webView: UIWebView
  3. Instantiate a NSURLRequest, with a NSURL object set with the right url as string, and finally assign this NSURLRequest to the webview by calling loadRequest:

    let requestURL = NSURL(string:url) let request = NSURLRequest(URL: requestURL!) webView.loadRequest(request)