OGeek|极客世界-中国程序员成长平台

标题: ios - UICollectionViewCell 中的 UILabel [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-13 17:15
标题: ios - UICollectionViewCell 中的 UILabel

我在storyboard中设计了UICollectionViewCell。由UILabel、UIImageView两个元素组成。

对于 UILabel 我给定的约束前导=0,尾随=0,底部=0,高度=100

我的collectionViewCell enter image description here

但是当我在模拟器中运行时: enter image description here

编辑:当我在界面检查器中观察时,标签未附加到 collectionView 上的 View : enter image description here



Best Answer-推荐答案


我通过在 cellForItemAtIndexPath 中添加这些行来解决问题

[cell setNeedsLayout];
[cell layoutIfNeeded];

关于ios - UICollectionViewCell 中的 UILabel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38203408/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4