Yog*_*tel 1 row-height uitableview tableview ios swift
这是一个故事板图像.我已经尝试了一个动态的tableviewcell我已经尝试过拖放并UITableViewCell从故事板中更改行高,它不能在运行时扩展单元格高度.
在Xcode 9.0.1和Swift 4,我面临的问题是细胞高度在运行时没有增加.所以,请帮助我解决这个问题.
要设置行高和估计行高的自动尺寸,请确保执行以下步骤,自动尺寸对单元格/行高度布局有效.
UITableViewAutomaticDimension给rowHeight和estimatedRowHeightheightForRowAt返回一个值UITableViewAutomaticDimension)-
@IBOutlet weak var table: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
// Don't forget to set dataSource and delegate for table
table.dataSource = self
table.delegate = self
// Set automatic dimensions for row height
table.rowHeight = UITableViewAutomaticDimension
table.estimatedRowHeight = UITableViewAutomaticDimension
}
// UITableViewAutomaticDimension calculates height of label contents/text
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableViewAutomaticDimension
}
Run Code Online (Sandbox Code Playgroud)
对于UITableviewCell中的标签实例

| 归档时间: |
|
| 查看次数: |
4517 次 |
| 最近记录: |