【发布时间】:2015-10-31 02:42:01
【问题描述】:
我正在创建一个屏幕,想象一下 facebook 个人资料屏幕。一个 tableview 和第一个单元格是一个图像。目标是该图像保持纵横比,因此对于不同的屏幕尺寸,我不必担心它的大小。
我无法让它与任何视图一起使用,即使我设置了特定的约束,单元格也不会设置正确的高度..
我有一个显示约束的小项目,在这个链接中..
我的 VC 代码:
class ViewController: UITableViewController{
override func viewDidLoad() {
super.viewDidLoad()
self.tableView.dataSource = self
self.tableView.delegate = self
self.tableView.estimatedRowHeight = 100
self.tableView.rowHeight = UITableViewAutomaticDimension
self.tableView.reloadData()
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath)
return cell
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 1
}
}
【问题讨论】:
标签: ios iphone swift uitableview