我有一个TableViewController和一个TableView,它的行动态设置有自动布局.
我向Controller添加了另一个TableView,它用于菜单。它的行高需要设置在65。
问题是,在heightForRowAtIndexPath.中我知道如何为这个tableView菜单的行返回65。但是我不知道如何让自动布局来完成它仍然是另一个tableView的事情。
有人知道我怎么能做到这一点吗?
这是我的密码:
override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
if tableView is YALContextMenuTableView {
return 65
} else {
}
}
发布于 2015-09-02 17:47:59
tableView:heightForRowAtIndexPath:
。调整菜单tableView单元格的自动布局和自调整大小,因此它的约束大小为其高度(至65),或tableView:heightForRowAtIndexPath:
。返回非菜单UITableViewAutomaticDimension
单元格的高度,这将使系统可以自行调整这些单元格的大小。自我调整将是首选的方式,因为它与动态类型和自适应UI很好地结合使用。
发布于 2015-09-02 17:47:49
您可以使用super
使用UITableViewController
实现此方法。
override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
if tableView is YALContextMenuTableView {
return 65
} else {
return super.tableView(tableView, heightForRowAtIndexPath:indexPath)
}
}
https://stackoverflow.com/questions/32359783
复制相似问题