【发布时间】:2017-03-10 02:56:07
【问题描述】:
仅显示适合屏幕的单元格。如果滚动到下一个(屏幕外)单元格,则仅显示白屏。它允许滚动,但只显示空白。即使最后一行显示了一半,也只剩下一半。
extension LiveTVController: UITableViewDataSource,UITableViewDelegate {
func numberOfSections(in tableView: UITableView) -> Int {
return 10
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 1
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let reuseIdentifier = tableView.tag == 1 ? ProgrammeListCell.reuseIdentifier : StreamListCell.reuseIdentifier
let cell = tableView.dequeueReusableCell(withIdentifier: reuseIdentifier, for: indexPath)
if let cell = cell as? StreamListCell {
cell.programmeList.delegate = self
cell.programmeList.dataSource = self
}
return cell
}
func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
return tableView.tag == 2 ? 10 : 0
}
现在向下滚动以查看下一行。总共返回 10 个部分,每个部分有 1 行。
【问题讨论】:
-
表格视图是否存在于滚动视图中?单元格内是否存在滚动视图?视图中是否存在手势识别器?查看您的 UI,您似乎已向左/向右滑动以在屏幕之间导航,请确认。
-
@Windindi 我在主视图上有 tableView,在 tableview 单元格中有集合视图。
-
为什么你的tableView有10个section?每个部分只有 1 条记录?
-
我想在两行之间留出一些空间,所以我没有创建 10 行,而是创建了 10 个部分,每个部分有 1 行,并将页脚视图返回到高度为 10 pt 的每个部分。给定的值是硬编码的。测试用户界面。
标签: ios ios-simulator swift3 xcode8