我试图让 UITable View 用我提供的选项填充整个 View 。截至目前,我有四个选择。这是我正在运行的代码:
func tableView(tableView: UITableView,
heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
if indexPath.row == 1 {
return (screensize.height-70)/4 //Whatever fits your need for that cell
} else {
return (screensize.height-70)/4 // other cell height
}
}
70 来 self 页面顶部的导航栏,它占用 70 像素。我的问题是,无论如何我都会在模拟器的底部得到某种空白缓冲区。即使使用硬编码值,我似乎也无法填充显示。它将显示前 3 个选项,然后您必须滚动到第四个选项。请帮忙。
更新:设置我使用的表格尺寸:
tableView.frame = CGRectMake(0, 71, screenSize.height-70, screenSize.width);
最佳答案
试试这些来获取您的屏幕
宽度和高度
let width = UIScreen.mainScreen().bounds.size.width
let height = UIScreen.mainScreen().bounds.size.height
然后使用这些值用 scrollView
或您需要的任何其他 view
填充您的 View 。
关于ios - 如何使表格 View 快速实用地填充整个 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34684981/