iOS7:UICollectionView出现在UINavigationBar下 [英] iOS7: UICollectionView appearing under UINavigationBar

查看:144
本文介绍了iOS7:UICollectionView出现在UINavigationBar下的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在iOS 7上构建了一段时间但是我还没有解决这个问题,我在Storyboard中创建了一些启用了autolayout的视图,并以标准的UINavigationController 。大多数都很好,但基于 UICollectionView 的那些总是置于导航栏下,除非我将半透明度设置为。我已经尝试了 edgesExtended 技巧,但这似乎没有解决它,我不一定介意关闭半透明但我想解决它更干净。

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 UINavigationController. The majority are fine, but the ones based on UICollectionView always place themselves under the navigation bar, unless I set the translucency to NO. I've tried the edgesExtended 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)];

其中topMargin是导航栏的大小,或者您希望集合开始滚动的任何点。

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.

这篇关于iOS7:UICollectionView出现在UINavigationBar下的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆