質問

私は2番目のtableHeaderViewを上書きしようとしました。しかし、それは私がviewForHeaderInSectionに、私は何の問題もなくビューを設定することができますので、IVARに入れなければならないのは、この方法でそれの高さはheightForHeaderInSection 0がそれを説明することはできませんのようだと思われます。

 - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
if(section == 0)
    return @"Adding a new list";
else
    return @"Other lists";

}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {

if(section == 0) {
    return tableView.tableHeaderView;
} else {
    UIView *view = [[[UIView alloc] initWithFrame:CGRectMake(10, 10, 100, 50)] autorelease];
    view.backgroundColor = [UIColor redColor];

    return view;
}

}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
if(section == 0)
    return tableView.tableHeaderView.frame.size.height;
else
    return 30;
}
役に立ちましたか?

解決

私は、彼らが異なっている、あなたは、テーブルヘッダと各セクションのヘッダーが混乱していると思います。何の「第二tableHeaderViewは」UITableViewは1 tableHeaderViewがあり、その後、そうでなければ、ただそこにテキストを配置するviewForHeaderInSectionを使用し、各セクションのカスタムヘッダービューを配置するheightForHeaderInSectiontitleForHeaderInSection方法に依存して、ありません。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top