Question: I am a beginner in iOS development and I have been having difficulty adding WKWebview with code. I intend to make it full width too but I get an empty screen.

```
var webView = WKWebView()
var activityIndicatorView: ActivityIndicatorView!

override func viewDidLoad() {
    super.viewDidLoad() 
     //show Activity Indicator
    self.activityIndicatorView = ActivityIndicatorView(title: "Loading content...", center: self.view.center)
    self.activityIndicatorView.startAnimating();
    self.view.addSubview(self.activityIndicatorView.getViewActivityIndicator())self.view.addSubview(self.activityIndicatorView.getViewActivityIndicator())
    // Do any additional setup after loading the view.
    let urlString = "http://www.youtube.com";
    let request = URLRequest(url:URL(string: urlString)!)
    self.webView.load(request)
     self.view = webView
}

```

Answer: 
```
let webview = WKWebView()
    webview.frame  = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: 100)
    webview.load(URLRequest(url: Bundle.main.url(forResource: "index", withExtension:"html", subdirectory: "subdirectories")! as URL) as URLRequest)
    self.view.addSubview(webview)

```
You are creating a webView with zero frame, that's why it's not showing. 

Change `webView = WKWebView(frame: .zero)` to this: 

```
webView = WKWebView(frame: self.view.frame)

```

To display the activity indicator while loading the page, you need to implement `WKNavigationDelegate` delegate. Update your code to this: 

```
class ViewController: UIViewController, WKNavigationDelegate {
    var webView = WKWebView()
    var activityIndicatorView: ActivityIndicatorView!

    override func viewDidLoad() {
        super.viewDidLoad() 
         //show Activity Indicator
        self.activityIndicatorView = ActivityIndicatorView(title: "Loading content...", center: self.view.center)
        self.activityIndicatorView.startAnimating();
        self.view.addSubview(self.activityIndicatorView.getViewActivityIndicator())self.view.addSubview(self.activityIndicatorView.getViewActivityIndicator())
        // Do any additional setup after loading the view.
        let urlString = "http://www.youtube.com";
        let request = URLRequest(url:URL(string: urlString)!)
        self.webView.navigationDelegate = self // Add this line!
        self.webView.load(request)
    }

    func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
        self.view = webView
        // Hide activity indicator here
    }
}

```