Skip to content

Instantly share code, notes, and snippets.

Last active Aug 29, 2015
What would you like to do?
static NSInteger currentTopVisibleSection = -1;
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
NSIndexPath *topCellPath = [[tableView indexPathsForVisibleRows] objectAtIndex:0];
if (currentTopVisibleSection != topCellPath.section) {
currentTopVisibleSection = topCellPath.section;
NSLog(@"current section on top is %d", currentTopVisibleSection);
NSString *header = [NSString stringWithFormat:@"Section %d", section];
return header;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment