作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个 UICollextionView
,它目前正在计算 UILabel
的高度。每个标签都有自己的高度。我现在想对 Collection View 单元格做同样的事情。我似乎只能将它们全部更改为相同。我应该怎么办?谢谢
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier("Cell", forIndexPath: indexPath) as ChatCellCollectionViewCell
cell.backgroundColor = UIColor.whiteColor()
cell.layer.cornerRadius = 10
cell.textLabel.text = "\(messageArray[indexPath.row])"
cell.nameLabel.text = "\(namesArray[indexPath.row])"
cell.textLabel.numberOfLines = 0
cell.textLabel.lineBreakMode = NSLineBreakMode.ByWordWrapping
frame = cell.textLabel.frame
cell.textLabel.sizeToFit()
frame.size.height = cell.textLabel.frame.size.height
cell.textLabel.frame = frame
return cell
}
最佳答案
如果您使用的是流布局,UICollectionViewDelegateFlowLayout
协议(protocol)有一个名为 collectionView:layout:sizeForItemAtIndexPath:
的函数,它允许您执行此操作。
关于ios - UICollectionView 单元格个体高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27409616/
我想向从 protege 创建的 OWL 文件添加一个新类、属性。我需要更新 owl 文件。这是我尝试添加类的代码。但它并没有更新原始的OWL文件。只有 netbeans IDE 的输出提供更新的 O
我在 eclipse 3.4 中使用 OWL Api 4.0,在 Protege 4 中使用简单的本体。我有两个类“Ward”和“Gaurdian”。这些类的个体通过对象属性 isWardOf 关联。
我是一名优秀的程序员,十分优秀!