1

I have added a WKWebView to the header of my tableViewController. I would like the WKWebView to change it's height according to the content height of the WKWebView.

I've seen a lot of how to do it with a UIWebView, but since that is deprecated I chose a WKWebView - it just does not seem like it is possible to do?

Have anyone tried this? Have an idea of how to do this or just something to point me in the right direction?

I have set constraints from the WKWebView to top, leading, trailing, bottom of the UIView (tableView Header).

class detailTableViewController: UITableViewController, WKUIDelegate {

    @IBOutlet weak var webView: WKWebView!   

    var data = Data()


    override func viewDidLoad() {
        super.viewDidLoad()


        self.tableView.delegate = self
        self.tableView.dataSource = self
        webView.uiDelegate = self

        let url = URL(string:"http://myweb.com")
        let req = URLRequest(url:url!)
        self.webView!.load(req)

        self.webView!.scrollView.isScrollEnabled = false
        self.webView.sizeToFit()





    }

// Stuff here too

}
D. Finna
  • 467
  • 2
  • 7
  • 19

0 Answers0