0

I have a view controller which has various components while a webview at its bottom everything is inside ScrollView but I ended up with double scroll one of main scrollview and one in the webview. How can I set the height of the main view to increase dynamically so that the webview would take its full height and I don't get a double scroll? I have tried something like this:

func webViewDidFinishLoad(webView: UIWebView) {

        myWebView.frame.size.height = 1
        myWebView.frame.size = webView.sizeThatFits(CGSizeZero)
    }

from this answer :here

As suggested in the answer below I did this

mainScroll.contentSize = CGSizeMake(mainScroll.contentSize.width, mainScroll.contentSize.height + webView.scrollView.contentSize.height);

that increased the height of scrollview according to content size of webview but the height of UIWebview remaided the same..

Community
  • 1
  • 1
theUturn
  • 1,101
  • 2
  • 12
  • 25

1 Answers1

3

In Web view delegate method where it tells that loading has finished, you can do following

mainScroll.contentSize = CGSizeMake(mainScroll.contentSize.width, mainScroll.contentSize.height + webView.scrollView.contentSize.height);

I think this will work.

To increase the size of web view

webView.frame = CGRectMake(webView.frame.origin.x, webView.frame.origin.y, webView.frame.size.width, webView.scrollView.contentSize.height);
Davinder Singh
  • 645
  • 3
  • 12