2014-03-29 4 views
0

UITableView에서 첫 번째 섹션의 헤드를 숨기고 싶습니다. 따라서 다음 함수에서 높이를 0으로 설정합니다. 그러나 헤더가 여전히 표시됩니까? 뭐가 문제 야? 예를 들어로 설정하면 1 테이블 꼭대기에 작은 선이 보인다. 어떤 아이디어?UITabllView의 섹션 헤더 숨기기

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section 
{ 
    if (section == 0) { 
     return 0; 
    } else { 
     return 18; 
    } 
} 
+0

같은 문제를 설명하지만 (아래 참조) 더 나은 솔루션을 발견 http://stackoverflow.com/questions/1386826/uitableview-not-respecting-heightforheaderinsection-heightforfooterinsection – NathanAldenSr

+0

의 중복처럼 보인다. – Morpheus78

답변

1

이 문제는 viewDidLoad() 메소드에 다음 코드 줄을 추가하여 해결되었습니다. 또한 heightForHeaderInSection의 높이를 1.0f로 설정합니다 (위의 메서드 참조).

// Correct position because section header height will be set to 1 in order to hide it. 
self.tableView.contentInset = UIEdgeInsetsMake(-1.0f, 0.0f, 0.0f, 0.0); 
+0

깔끔함! 나는 이것을 기억할 것이다. :) – NathanAldenSr