更改tableHeaderView的高度会隐藏单元格 [英] Changing the height of a tableHeaderView hides the cells
问题描述
在我的UITableView中,我有一个tableHeaderView,它应该根据内容调整自己的大小。调整大小很好,但是,tableHeaderView模糊了前几个单元格。显然更改tableHeaderView的框架不会重新组织视图的其余部分。
In my UITableView, I have a tableHeaderView that should resize itself according to the content. The resizing works fine, however, the tableHeaderView obscures the first couple of cells. Apparantly changing the frame of the tableHeaderView doesn't reorganize the rest of the view.
我已经尝试调用 [self.tableView layoutSubViews]
和 [self.tableView setNeedsLayout]
,但这些也没有帮助。还尝试从Interface Builder中提供tableHeaderView一个插座来改变它的框架,但是也没有重新组织tableView。
I've already tried calling [self.tableView layoutSubViews]
and [self.tableView setNeedsLayout]
, but those don't help either. Also tried giving the tableHeaderView from the Interface Builder an outlet to change the frame on that, but that doesn't reorganize the tableView either.
如何更改大小tableHeaderView,没有隐藏任何单元格,重新组织tableView的其余部分?
How can I change the size of the tableHeaderView, without hiding any cells, reorganizing the rest of the tableView?
推荐答案
我不知道你是如何创建UITableView的,但我尝试使用像你这样的tableHeaderView来创建一个,并且它正在调整大小。
I don't know how you created you UITableView, but I tried to create one with a tableHeaderView like you and it's resizing.
我创建了一个继承自UITableViewController的类
I created a class inheriting from UITableViewController
@interface MyTableViewController : UITableViewController {
}
@end
并且对于实现,在viewDidLoad中,我添加了:
and for the implementation, in the viewDidLoad, I added:
UIView *header = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 100)];
[header setBackgroundColor:[UIColor redColor]];
self.tableView.tableHeaderView = header;
这篇关于更改tableHeaderView的高度会隐藏单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!