简体   繁体   English

在dequeueReusableCell之后的单元格布局

[英]Cell layout right after dequeueReusableCell

Can I assume that after getting a cell from let cell = tableView.dequeueReusableCell() the cell will have all it's contents sizes (specifically - will be laid out) and I can safely access fe the width of a label that's residing inside the cell? 我可以假设从let cell = tableView.dequeueReusableCell()获得一个单元格之后,该单元格将具有其所有内容的大小(特别是-将被布局),并且我可以安全地访问位于该单元格内的标签的宽度吗?

It seems to be working in my project, but I wanted to be totally shure, but cannot find relevant information in docs. 它似乎在我的项目中正常工作,但我想完全确定,但无法在文档中找到相关信息。

如果要获取单元格中存在的标签宽度,则可以使用tag属性获取标签及其宽度。

Much more reliable: 更可靠:

override func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
    // do your setup tasks here
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 表初始化后,dequeueReusableCell返回空单元格 - dequeueReusableCell returns empty cell after table initialization 当 Cell 位于自己的 class 中时,我无法 dequeueReusableCell - I can't dequeueReusableCell when the Cell is in its own class 为什么我们需要上流通过dequeueReusableCell函数获得的单元格? - Why do we need upcasting cell obtained by dequeueReusableCell func? 点击单元格后不同的 UITableViewCell 子视图布局 - Different UITableViewCell subviews layout after tapping a cell TableView重新加载数据后,TableView单元格布局错误 - Tableview cell layout incorrectly after the tableview reloaddata UITableView:创建后更新单元格(正确的方法) - UITableView : Cell update after creation ( the right approach) 在tableView中选择单元格后布局发生更改 - Layout changes after selecting cell in tableView 删除UICollectionView中的一个单元格后刷新单元格布局 - Cell Layout refresh after deleting one cell in UICollectionView 即使在将图像设置为nil时,UITableView单元也显示不正确的图像,这是tableView.dequeueReusableCell的第一步 - UITableView cell is displaying an incorrect image, even while setting the image to nil as the first step in tableView.dequeueReusableCell dequeueReusableCell 问题。 当我选择一个单元格时,正在选择另一个单元格 - dequeueReusableCell problem. When I select one cell, another cells are being selected
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM