Reputation: 23
I am creating an app that uses WKWebView to display a website. However, when I run this (in ViewController.swift):
import UIKit
class ViewController: UIViewController {
@IBOutlet var WebsiteView: WKWebView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
WebsiteView.loadHTMLString("<iframe width=\"\(WebsiteView.frame.width)\" height=\"\(WebsiteView.frame.height)\" src=\"http://example.com\"></iframe>", baseURL: nil)
}
}
it throws 2 errors. The main one is this:
Cannot find type 'WKWebView' in scope
The other one is this:
'nil' requires a contextual type
.
Any help would be appreciated!
Upvotes: 0
Views: 1907
Reputation: 894
You need to import a Framework. Under import UIKit
add
import WebKit
Upvotes: 1