简体   繁体   中英

Resizing UIView to match its content

I have a UITextField, a UIButton, and a UIWebView nested in a UIView, which is nested in a UIScrollView. After the UIWebView has loaded its content, I need it to resize the UIWebView and UIView so that the UIScrollView will scroll.

I currently have the UIScrollView getting its contentSize from the UIView, but I can't figure out how to do the resizing after the UIWebView's content has loaded.

if you implement - (void)webViewDidFinishLoad:(UIWebView *)webView in the webview's delegate object, you can determine whatever size you need the webview to be, and then resize the webview and parent views from there; make sure you also reset the contentSize of the scrollview as well.

If you want to resize your webview to fit all of its content though then you'll have a problem, since i don't believe that is possible.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM