-
Notifications
You must be signed in to change notification settings - Fork 472
Using UIWebView
Charlie Hieger edited this page Nov 6, 2015
·
18 revisions
Loading a URL into your app is as easy! Just add and configure a UIWebView.
Drag and drop a UIWebView from the Object Library to the main view of your ViewController.
Choose: File -> New -> File...-> iOS -> Cocoa Touch Class
Create an outlet for the WebView by ctrl + dragging from the WebView in the Storyboard to your custom ViewController swift file.
Above the viewDidLoad
method, create a constant to hold your URL string. We will link to the DropBox mobile terms url.
let url = "https://www.dropbox.com/terms?mobile=1"
Within the viewDidLoad
method...
// Convert the url String to a NSURL object.
let requestURL = NSURL(string:url)
// Place the URL in a URL Request.
let request = NSURLRequest(URL: requestURL!)
// Load Request into WebView.
webView.loadRequest(request)