[英]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.