ios - 当 extendedLayoutIncludesOpaqueBars 设置为 true 时,UICollectionView 不工作

标签 ios swift uicollectionview

我有 UIViewController,它扩展了 UICollectionViewDataSource、UICollectionViewDelegate、UICollectionViewDelegateFlowLayout。

override func viewDidLoad() {
    super.viewDidLoad()
    collectionView.delegate = self
    collectionView.dataSource = self
    self.extendedLayoutIncludesOpaqueBars = true

}

没有调用 UICollectionviewDelegate 和 DataSource 方法,因此 UICollectionview 看起来是空的。即使我调用重新加载数据,仍未调用 DataSource 方法。

当我删除最后一行时,除了 viewController 下方有空间外,一切正常。

最佳答案

edgesForExtendedLayout

Basically, with this property you set which sides of your view can be extended to cover the whole screen. Imagine that you push a UIViewController into a UINavigationController, when the view of that view controller is laid out, it will start where the navigation bar ends, but this property will set which sides of the view (top, left, bottom, right) can be extended to fill the whole screen.

你需要设置这两个中的一个

self.edgesForExtendedLayout = UIRectEdgeNone;
self.automaticallyAdjustsScrollViewInsets = NO;

self.edgesForExtendedLayout = UIRectEdgeNone;
self.extendedLayoutIncludesOpaqueBars = YES;

也许它会对你有所帮助。

关于ios - 当 extendedLayoutIncludesOpaqueBars 设置为 true 时,UICollectionView 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34176097/

相关文章:

ios - 如何快速加载 View 多次?

ios - 重新启动应用程序后,如何在 Collection View 中保存重新排序的单元格的位置? swift

IOS Swift 表格 View : Is there a way to move first cell one row down

swift - 全屏按钮已禁用

ios - 如何解决将应用程序上传到 ios 中的应用程序商店时出现的问题

swift - 两个不同单元格的 TableView 相同的 cellForRowAt 用法

ios - 如何连接到 tableview 容器?

c# - Xamarin 表单 DisplayAlert 在从委托(delegate)调用的函数调用时不显示

ios - 如果在 ios 6 中删除了文档文件夹,如何重新创建它?

ios - 如何用windows PC调试ios.iphone网站