首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Autolayout在Xcode-9测试版中中断

Autolayout在Xcode-9测试版中中断
EN

Stack Overflow用户
提问于 2017-06-22 09:46:06
回答 1查看 1.2K关注 0票数 1

我的屏幕上有UITableView。它显示具有动态高度的节标题和行。

当我从Xcode8.3迁移到Xcode-9测试版时,这个设置有两个问题。

1头视图高度断裂的

2行的动态高度断裂

我把我的桌景设置为:

那我就有定制的牢房了

这是代码:

代码语言:javascript
复制
func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
    return //dynamically calculated height according to msg text
}
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
    return 30
}

func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
    let headerHeight:CGFloat = tableView.sectionHeaderHeight
    let headerView = HeaderView(frame: CGRect(x: 0, y: 0, width: tableView.width, height: headerHeight), withHeaderLable: "Date/Day of msg")
    return headerView
}

这在Xcode8.3中工作得很好,即使有多行消息,但是在Xcode9测试版中被破坏了:当我在Xcode9 beta中使用Swift3.2设置运行时:

当我在Swift4测试版中使用Xcode9设置运行时:

这种行为的原因是什么?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-06-22 11:22:16

代码语言:javascript
复制
tableView.rowHeight = UITableViewAutomaticDimension
tableView.estimatedRowHeight = 30.0

将其添加到您的viewDidLoad中,而不需要使用tableview委托方法estimatedHeightForRowAt

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44695865

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档