2017-06-22 104 views
1

我在我的屏幕中有UITableView。它显示部分标题和行与动态高度
当我从Xcode8.3移到Xcode-9 beta时,这个设置有两个问题。在Xcode-9 beta中破解的Autolayout

1接头视图高度破碎
2行的动态高度破碎

我已建立我的表视图为:

enter image description here enter image description here

然后,我有自定义单元格

enter image description here
enter image description here
enter image description here

这里是代码:

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公测破为: 当我与Swift3.2设置运行在Xcode9测试:

enter image description here

当我在Xcode9赌注Swift4设置运行答:

enter image description here

什么是这种行为的原因是什么?

+0

你为什么使用测试版? –

+4

@elk_cloner这应该是问题,为什么使用测试版。这是一项采用即将到来的技术挑战的举措。如果这真的是Apple的缺陷,那么对我们来说,面对这样的挑战并找到适当的解决方案 – Krunal

回答

3
tableView.rowHeight = UITableViewAutomaticDimension 
tableView.estimatedRowHeight = 30.0 

viewDidLoad添加这一点,并没有必要的tableview委托方法estimatedHeightForRowAt的。

+0

难怪为什么它需要xcode9而不是xcode8.3! – D4ttatraya

+0

实际上,标题问题与自动布局无关,它与'NSFetchedResultsController'有关; [这是关于这个问题](https://stackoverflow.com/q/44804683/5546312) – D4ttatraya