2. Drag the web view to the storyboard.
@IBOutlet weak var myWebView: UIWebView!
4. Complete the code as below:
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var myWebView: UIWebView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
let myURL : NSURL = NSURL(string: "
https://www.youtube.com/embed/vmMAI86Lub0")!
//Note: use the "embed" address instead of the "watch" address.
https://www.youtube.com/embed/vmMAI86Lub0")!
//Note: use the "embed" address instead of the "watch" address.
let myURLRequest : NSURLRequest = NSURLRequest(URL: myURL)
self.myWebView.loadRequest(myURLRequest)
}
No comments:
Post a Comment