使用节时是否可以有固定的uitableview标头? [英] Is it possible to have a fixed uitableview Header while using sections?
问题描述
此问题不应与此处此处混淆..这是两件事.
This question should not be mixed up with this here.. These are two different things.
有一个好示例如何使用UITableView标头在SO上.
There is a good example how to use a UITableView Header on SO.
这一切都很好,只要将样式设置为plain
,主标头就固定在顶部.
This all works fine and the main header is fixed on top as long as the style is set to plain
.
但是,如果我使用sections
,则主页眉不再停留在顶部,而是在滚动到底部时移开.
But if I use sections
, the main header no longer sticks to top and moves away while scrolling to the bottom.
在此方法中,我将返回每个节的标题.
In this method, I am returning the header for each section.
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
在这种方法中,我为上面的标题区域设置高度:
In this method I am setting the height for the header section above:
- (CGFloat) tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
在这种方法中,我设置了真实的表头.
In this method, I am setting the real table header.
- (void)viewWillAppear:(BOOL)animated {
...
self.recordTableView.tableHeaderView = headerView;
}
在使用节时,甚至有可能具有固定的表头? 请问有什么替代解决方案?
Is it even possible having a fixed table header, while using sections? What is an alternative solution to this please?
推荐答案
无法维护固定的tableView
头文件,但是
当您需要唯一标头时,一种有用的方法是使用UIViewController
而不是UITableViewController
,然后从tableView
设置标头(UIView
) out .
There’s no way to maintain the header of a tableView
fixed, but
an useful approach when you need a unique header, is to use a UIViewController
rather than a UITableViewController
, and set the header (UIView
) out from the tableView
.
类似这样的东西:
这篇关于使用节时是否可以有固定的uitableview标头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!