Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIWebView contentInset without extra height at bottom

I'm creating a view controller that uses a web view which slides behind the navigation bar and status bar. To do this, I'm setting the webView.scrollView.contentInset property to have a top inset of 64.

However, this doesn't shrink the amount of area the web view wants to take up, so if a page is less than a screenful, it has 64 px of white space at the bottom to scroll through. The web views are in a vertical UIPageViewController, so this disrupts paging. Is there some way to get rid of this extra space?

like image 399
Becca Royal-Gordon Avatar asked Jun 28 '13 06:06

Becca Royal-Gordon


3 Answers

Have you tried something like adjusting the webview's scrollview content insets? Example:

    webView.scrollView.contentInset = UIEdgeInsetsMake(0, 0,64, 0)
like image 103
royherma Avatar answered Nov 20 '22 17:11

royherma


It sounds like what you need is to adjust the webView.scrollView.contentSize and adjust the height by 64. You may need to provide more information about how it slides behind the nav bar and status bar to help me answer this. I would take a look at this section of the Scroll View Programming Guide:

http://developer.apple.com/library/ios/#documentation/WindowsViews/Conceptual/UIScrollView_pg/CreatingBasicScrollViews/CreatingBasicScrollViews.html

like image 43
Chris Truman Avatar answered Nov 20 '22 16:11

Chris Truman


Change the clipsToBounds.

webView.clipsToBounds = NO;

This will make its content visible outside its frame, so set its frame like normal, right under the navigation bar. The navigation bar will be translucent and you will see its content under it.

like image 1
Maximilian Litteral Avatar answered Nov 20 '22 15:11

Maximilian Litteral