I have a problem with UIWebView
on iOS7:
First I'm setting the content inset for my web view scrollview:
[webView.scrollView setContentInset:UIEdgeInsetsMake(40, 0, 0, 0)];
Then when web view loads an empty page there is a black rectangle at the bottom of the web view, that has the height 40.
It's for sure because of content inset, and I met this problem only on iOS7. How can I solve this? Any help will be appreciated!
Try this code, it is not the best solution, but it will get rid the black rectangle:
[webView.scrollView setContentInset:UIEdgeInsetsMake(40, 0, -40, 0)];
From my experience, iOS7 UIWebView
does not play nice at all with custom insets and content size. It always breaks under certain conditions. We use a webview for a rich text editor, so we had to manage a volatile contentEditable="true"
webview.
What we ended up doing was to take the UIWebDocumentView
/UIWebBrowserView
(let's call it "internal view") from the UIWebScrollView
and add it as a subview in a scrollview of our own. To do this safely, we iterate the subviews of webView.scrollView
and took the one whose class name has a UIWeb
prefix. (You have to remember that iOS6 UIWebScrollView
contains shadows as well.)
Now you have to manage your scrollview. What we did was observe changes of the frame
property of the internal view and update the scrollview's contentsize accordingly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With