I have a custom UIView with its xib. The xib is empty except the content view.
In the corresponding class I load the xib, then I try to create a WKWebView like this :
@IBOutlet var contentView: UIView!
...
Bundle.main.loadNibNamed("CustomView", owner: self, options: nil)
addSubview(contentView)
contentView.frame = self.bounds
let webConfiguration = WKWebViewConfiguration()
webView = WKWebView(frame: self.frame, configuration: webConfiguration)
webView.translatesAutoresizingMaskIntoConstraints = false
contentView.addSubview(webView)
webView.backgroundColor = UIColor.orange // Just to check visually
And in my UIViewController :
let v = CustomView.init(frame: frame)
self.view.addSubview(v)
When I run my project, when the view controller appears I can see the Web view with its orange background but it disappears immediately, what is wrong in my code ?