Reputation: 9823
Can I init a UiWebView through code, load the url (cache the page per say) and then on cellForRowAtIndex just assign my webView to the one on the cell? If so, how can I get the page height if the webview is just sitting in code
Upvotes: 1
Views: 497
Reputation: 5290
First, an obligatory warning about putting a UIWebView
, which contains UIScrollView
, inside a UITableView
, which derives from a UIScrollView
. You've been warned.
I'm not aware of any reason you can't load the UIWebView when it's not in the view hierarchy. I've never explicitly tested it, but it should work. Watch your threading.
As far as getting the size goes, there are a few ways. All of them have limitations. One way is to use UIWebView -stringByEvaluatingJavaScriptFromString:
and requesting the body height. This works well most the time, but it sometimes the content can extend outside the body, which messes it up.
Another solution is to look at webView.scrollView.contentSize
. This can work, but it not perfect. I haven't narrowed down when this works or not, but it CAN work.
Upvotes: 2