I'm a new in Swift/iOS developing. I try to create a simple browser:
import UIKit
import WebKit
class ViewController: UIViewController, WKNavigationDelegate {
var webView: WKWebView!
override func loadView() {
webView = WKWebView()
webView.navigationDelegate = self
view = webView
}
override func viewDidLoad() {
super.viewDidLoad()
let url = URL(string: "https://www.instagram.com")!
webView.load(URLRequest(url: url))
webView.allowsBackForwardNavigationGestures = true
}
}
When I go to https://www.instagram.com, I can't see my messages.
I got this (top header isn't shown):
But I expect this (top header is shown):
Why I can't see the top header through my browser?
I'm able to see the header at my end. The only difference is that I've added WKWebView in XIB and you are loading on view from the code.
Reason can be the frame & constraints of the page. Try setting frame & constraints -
webView = WKWebView(frame: self.view.frame)
webView.translatesAutoresizingMaskIntoConstraints = true
webView.autoresizingMask = [.flexibleWidth, .flexibleHeight]