문제

두 번째 TableHeaderView를 무시하려고했습니다. 그러나 HeightorHeadErisection의 메소드 높이의 높이는 0 인 것 같습니다. 설명 할 수 없습니다. IVAR에 넣어야합니까?

 - (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", a UITableView 하나가 있습니다 tableHeaderView 그리고 다음에 의존합니다 viewForHeaderInSection 그리고 heightForHeaderInSection 각 섹션에 대해 사용자 정의 헤더보기를 배치하는 메소드, 그렇지 않으면 만 사용합니다. titleForHeaderInSection 거기에 텍스트를 배치합니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top