
我有一个UILabel,它有动态文本,位于12行内,我如何根据UILabel中的文本制作一个单元格的动态高度.
我在vIEwDIDLoad中尝试了以下代码,但它没有用.行保持相同的高度.我还为UILabel设置了lines = 0
tableVIEw.estimatedRowHeight = 100.0 tableVIEw.rowHeight = UItableVIEwautomaticDimension解决方法 你试过这个吗?
overrIDe func tableVIEw(tableVIEw: UItableVIEw,heightForRowAtIndexPath indexPath: NSIndexPath) -> CGfloat { if (indexPath.row < 11) { // Everything starts at 0,so this covers 0-10 // Whatever your cell height is return <#fixedCellHeight#> } else { // This is your 12th cell (indexPath.row 11),as we start counting at 0 return UItableVIEwautomaticDimension }} 总结 以上是内存溢出为你收集整理的ios – Static UITableView,在Swift中创建一个具有动态高度的单元格全部内容,希望文章能够帮你解决ios – Static UITableView,在Swift中创建一个具有动态高度的单元格所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)