17
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
if(section != 0) {
UIView *view = [[[UIView alloc] initWithFrame:CGRectMake(10, 10, 100, 30)] autorelease];
view.backgroundColor = [UIColor redColor];
return view;
} else {
return tableView.tableHeaderView;
}
這是我實現viewForHeaderInSection的但無論幀我讓它總是顯示我相同的紅色框。你看到我的代碼有問題嗎?
圖片:
UPDATE:
MHM現在我的紅塊較高,但我第一次的tableHeader現在以某種方式隱藏。第一個是用titleForHeaderInSection實現的。我想我只需要實現的tableHeader高度的高度,但是,這並不工作
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
if(section == 1)
return 30;
else
return tableView.tableHeaderView.frame.size.height;
}
thx,你知道他們爲什麼不採取無恥的身高嗎?不明白爲什麼我必須設置一個額外的代表方法的高度... – gabac 2010-03-15 20:15:15
我不知道爲什麼蘋果這樣做。這有點傻。但我認爲他們希望標題框架*始終*跨越表格視圖的整個寬度。所以剩下的唯一大小的變量就是高度。 – 2010-03-15 20:18:09
thx關於autorelease的提示。但是現在我有另外一個問題了,也許你可以再幫我一次嗎? – gabac 2010-03-15 20:23:22