我正在写一个iOS应用程序。 用户键入电影搜索关键字,并从omdbapi.com获取数据并在tableview中显示电影。 问题是表格视图单元格没有正确显示。
项目网址: project on onedrive
我尝试使用每种自动布局方法但是,它不起作用。
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableViewAutomaticDimension;
}
答案 0 :(得分:0)
您还需要为表格高度设置估算方法。所以将这些方法放在高度计算中,并检查细胞约束。
func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableViewAutomaticDimension
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableViewAutomaticDimension
}
希望这会对你有所帮助。