UICollectionView.backgroundView坏了

时间:2017-08-03 13:20:17

标签: ios swift uicollectionview

我的backgroundView属性有问题。我试图将imageView添加到这样的背景中

    let backgroundImage = UIImage(named: "Fridge_background")!
    let backgroundView = UIImageView(image: backgroundImage)
    collectionView?.backgroundView = backgroundView

但问题是它甚至没有将此视图添加到视图层次结构中。我已经阅读了this article,但这个解决方案也没有帮助我。它可以是什么,我怎么能解决它?有趣的是认为在tableView中类似的属性工作就好了。

2 个答案:

答案 0 :(得分:0)

确实破了。 我正在研究uicollectionview背景视图的不正确定位 并遇到这个:

https://blog.spacemanlabs.com/2013/11/uicollectionviews-backgroundview-property-is-horribly-broken/

也描述了您的问题。

答案 1 :(得分:0)

这似乎在UIColllectionViewController的{​​{1}}方法中效果很好。所有行为都符合预期。

viewDidAppear
相关问题