Ben Packard
Ben Packard

Reputation: 26476

Scroll bars with a translucent navigation bar

If you setTranslucent to YES on a UIViewController, it shifts the content 'up' (I suppose what it is really doing is not shifting it down).

Since all of my content is in a UIScrollView, the navigation bar is effectively covering the top of this scroll view. I can bump the items in the scroll view down a little, but the scroll indicators still get partially hidden under the nav bar.

I would consider moving the whole scroll bar down 44 points, except that's not going to look right in landscape orientation on an iPhone.

A vanilla UITableView seems to handle this scenario just fine - how can I do the same in my UIViewController?

EDIT

I've realized that I'm supposed to set contentInsets and scrollIndicatorInsets to 'shift' things down. But still my problem remains - In landscape mode, there is an ugly gap between the nav bar and the scroll view.

Upvotes: 1

Views: 3965

Answers (1)

Rob van der Veer
Rob van der Veer

Reputation: 1148

It took me 2 minutes to google this answer: contentInset

Check this question for an explanation: https://stackoverflow.com/a/10049782/2462469

After that you need to adjust ScrollIndicatorInsets as well.

http://developer.apple.com/library/ios/ipad/#documentation/UIKit/Reference/UIScrollView_Class/Reference/UIScrollView.html%23//apple_ref/occ/instp/UIScrollView/scrollIndicatorInsets

Edit: this fellow has similar rotation issues: https://stackoverflow.com/a/15623727/2462469 He needed to reset the scroll position after rotating back. It's an edge case though.

Upvotes: 1

Related Questions