0

On my project, I would like to display an UIWebView with a non-constant height and an UITableView with a non-constant height too.

So far, I tried to add an UIWebView and an UITableView in a UIScrollView, but it's not working.

Here's my current view (with just an UIWebView)

I'm new on iOs development, so if you have any lead, thank you :)

cappie013
  • 2,354
  • 1
  • 22
  • 30
  • So you want to have UIWebView on the top and table view below? – Yanchi Sep 14 '14 at 20:11
  • And if so, why don't you embed the `UIWebView` in a `UITableViewCell`? – freshking Sep 14 '14 at 20:16
  • @freshking I remember now : I can't set my cell height depending on the size of my `UIWebView` – cappie013 Sep 14 '14 at 21:44
  • Sure you can... I suggest getting height like this -> http://stackoverflow.com/questions/13123009/get-uiwebview-contents-height and then call reloadData on your tableview and in heightForRowAtIndexPath insert that height there. – Yanchi Sep 14 '14 at 21:54
  • Second approach is to have two different object in your view (webView and table view) and after getting height for your webview just change tableView's y-coordinate to be webview.frame.origin.y + webView.frame.size.height (or + computed height, depends on if you want to have webview with dynamic height) – Yanchi Sep 14 '14 at 21:56

1 Answers1

1

Try tableHeaderView

Init the webView first

Init the tableView

set tableView's tableHeaderView

tableView.tableHeaderView = webView
dopcn
  • 4,218
  • 3
  • 23
  • 32