ios - 使用 UICollectionReusableView 的 UITableView 自定义标题
问题描述
我目前正在使用 UICollectionReusableView 为 tableview 制作自定义标题。我面临的问题是这个标题没有像我想要的那样随着表格视图滚动。以下是我实现 headerview 的方式:
func numberOfSections(in tableView: UITableView) -> Int {
return 1;
}
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let headerView = Bundle.main.loadNibNamed("StoresListHeaderView", owner: self, options: nil)?.first as! StoresListHeaderView;
return headerView;
}
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return 170;
}
在 UICollectionReusableView .swift 文件中有默认代码,在 .xib 中只有一个 backgroundImage。
是否有任何布尔选项来设置它?否则你会用什么?
解决方案
如果不是,请尝试将 UITableView 的style
属性更改为。.plain
该.grouped
样式将在滚动时将标题保留在屏幕上。
推荐阅读
- jquery - 我将如何使用 jquery ajax 获取 html 文件元素的详细信息
- vba - 在 Excel 中关闭数据透视表快速浏览
- c++ - Boost.Asio:不能使用 std::bind() 来指定回调
- python - 从另一个不同大小的数组分配数组新值
- android - 将包含在 R.class 生成中并可以在布局中使用的生成的字符串资源放在哪里?
- javascript - 读取和加载内部 url 数组的下一个上一个链接
- c++ - 调用“项目”函数和调用 DLL 函数之间的区别
- google-apps-script - 用于分隔工作表上的数据行的代码:一种解决方案
- python - Python 3.6 中的并发异步函数调用
- android - 在您的父类上找不到方法