Skip to content

Commit 9b50115

Browse files
committed
Merge pull request facebookarchive#651 from facebook/empty_tttableviewheaders
Correctly Hide EmptyTTTableViewHeaders for iOS5 - closes #634
2 parents 254079a + d878d37 commit 9b50115

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/Three20UI/Sources/TTTableViewDelegate.m

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@
4343
// Core
4444
#import "Three20Core/TTCorePreprocessorMacros.h"
4545

46+
static const CGFloat kEmptyHeaderHeight = 0.f;
47+
static const CGFloat kSectionHeaderHeight = 22.f;
48+
static const CGFloat kGroupedSectionHeaderHeight = 36.f;
49+
static const CGFloat kGroupedSectionFirstHeaderHeight = 36.f + 10.f;
50+
static const NSUInteger kFirstTableSection = 0;
4651

4752
///////////////////////////////////////////////////////////////////////////////////////////////////
4853
///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -115,6 +120,27 @@ - (UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)
115120
return nil;
116121
}
117122

123+
///////////////////////////////////////////////////////////////////////////////////////////////////
124+
- (CGFloat)tableView:(UITableView*)tableView heightForHeaderInSection:(NSInteger)section {
125+
if ([tableView.dataSource respondsToSelector:@selector(tableView:titleForHeaderInSection:)]) {
126+
NSString* title = [tableView.dataSource tableView:tableView titleForHeaderInSection:section];
127+
if (![title length]) {
128+
return kEmptyHeaderHeight;
129+
}
130+
131+
if (tableView.style == UITableViewStylePlain) {
132+
return kSectionHeaderHeight;
133+
134+
} else {
135+
if (section == kFirstTableSection) {
136+
return kGroupedSectionFirstHeaderHeight;
137+
}
138+
return kGroupedSectionHeaderHeight;
139+
}
140+
141+
}
142+
return kEmptyHeaderHeight;
143+
}
118144

119145
///////////////////////////////////////////////////////////////////////////////////////////////////
120146
/**

0 commit comments

Comments
 (0)