当我将我的应用程序放入 iOS 7 时,顶部单元格被我的导航栏覆盖。 我尝试使用 edgesForExtendedLayout,但它只是给我一个 iOS 6 的应用程序外观。 我正在尝试利用 iOS 7 中的半透明栏,但 edgesForExtendedLayout 没有帮助。
有没有办法让这个单元格出现在导航栏下方?
最佳答案
您有多种选择。 UICollectionView
是 UIScrollView
的 subview 。
最简单的方法是将您的 View Controller 变成 UICollectionViewController
的子类,它会自动处理这些问题。更多信息 here .
如果不能,请在 View Controller 中将 automaticallyAdjustsScrollViewInsets
设置为 YES
,或者在 viewDidLayoutSubviews
中手动设置 Collection View 的 contentInsets像这样:
- (void)viewWillLayoutSubviews
{
[super viewWillLayoutSubviews]
[_collectionView setContentInset:UIEdgeInsetMake(self.topLayoutGuide.length, 0, self.bottomLayoutGuide.length, 0)];
[_collectionView setScrollIndicatorInsets: _collectionView.contentInset];
}
使用 UICollectionViewController
的额外好处是支持 useLayoutToLayoutNavigationTransitions
,它可以在 Collection View 布局(例如 Apple 的移动日历应用程序)之间创建很酷的过渡。
关于iphone - Collection View iOS 7,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19191515/