Nicholas Smith Nicholas Smith - 8 months ago 67
iOS Question

iOS7: UICollectionView appearing under UINavigationBar

I've been building on iOS 7 for a while now but I've yet to get this solved, I have a number of views with autolayout enabled that were created in Storyboard and are displayed with a standard

. The majority are fine, but the ones based on
always place themselves under the navigation bar, unless I set the translucency to
. I've tried the
trick but that doesn't seem to solve it, I don't necessarily mind having the translucency off but I'd like to solve it cleaner.


I had this problem before, just set the edge insents of the collection view with a top margin:

 [self.myCollectionVC.collectionView setContentInset:UIEdgeInsetsMake(topMargin, 0, 0, 0)];

Where topMargin is the size of the nav bar, or whatever point you want the collection to start scrolling.

In this way, your collection view will start scrolling just below the navigation bar, and at the same time it will fill the whole screen and you will see it if your nav bar is translucent.