我在tableView中使用UITableViewAutomaticDimension,它工作得很好,但是当装载表时,我需要单元格的行大小。桌子上的。有可能吗?
提前谢谢。
发布于 2017-08-18 15:31:17
使您的ViewController符合UITableViewDelegate,将表视图的delegate设置为该类,然后使用以下方法:
func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
let frame = cell.frame
[...]
}发布于 2017-08-18 15:28:44
你可以通过cell.frame获取它。如果你没有cell,但是有indexPath of cell,你可以这样做:
if let cell = tableView.cellForRow(at: indexPath) {
let size = cell.frame
}https://stackoverflow.com/questions/45750836
复制相似问题