【发布时间】:2016-10-28 17:04:48
【问题描述】:
【问题讨论】:
-
你设置了什么约束吗?
标签: ios xcode swift autolayout
【问题讨论】:
标签: ios xcode swift autolayout
在你的ViewController:
var remainingSpace = CGFloat()
在ViewDidLoad:
remainingSpace = self.view.frame.height - //The rest of the space that other views are taking up
self.table.reloadData()
在heightForRowAtIndexPath:
return remainingSpace
【讨论】:
如果您希望单元格相对于屏幕总高度具有特定高度,则以下代码将起作用:
let screenHeight = UIScreen.mainScreen().fixedCoordinateSpace.bounds.height
self.tableView.rowHeight = screenHeight / (how many cells)
希望这会有所帮助 - 干杯。
【讨论】:
无需以编程方式执行此操作,只需选择 tableview 并在右侧菜单选项中的大小检查器中提供其完整的布局约束。
对 tableview 单元格 xib 或 nib 也执行相同操作。
然后选择imageview并设置left和obtaints然后选择above label并设置above, right side, and heiht middle constriant然后设置第三个label在bottom to bottom和right side约束中。
它工作正常...
【讨论】: