Pla*_*gue 3 uitableview ios swift swift3
在将我的代码库从Swift 2.2迁移到Swift 3.0之后,我注意到我的UITableView页脚没有显示出来.事实证明,我的UITableViewDelegate方法都没有被调用(例如:)func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView?.
有趣的UITableViewDataSource是,正在调用这些方法,并且正在填充表格.我已将父视图控制器设置为表的delegate和dataSource.
为了说明这个问题,我创建了一个示例Swift 3.0项目,以便尽可能地匹配我现有的代码库.可能在Swift 3/Xcode 8中发生了一些我不知道的事情,或者我可能会遗漏一些非常明显的东西.谢谢您的帮助!
在我检查了您的示例项目之后:
你没有做错任何事,但是viewForFooterInSection在你实现heightForFooterInSection 方法之前,它不会被调用:
func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
return 50 // for example
}
Run Code Online (Sandbox Code Playgroud)
类似案例:
没有实现heightForHeaderInSection==> viewForHeaderInSection即使它已实现也不需要调用.
返回numberOfRowsInSection零==> cellForRowAt即使它已实现也不需要调用.
附加说明:您不必添加tableView.dataSource = self和tableView.delegate = self中viewDidLoad(),他们已经在界面生成器设置.
| 归档时间: |
|
| 查看次数: |
2160 次 |
| 最近记录: |