Skip to content

Instantly share code, notes, and snippets.

@dnnta
Last active August 29, 2015 14:02
Show Gist options
  • Save dnnta/cbd5f809a27508051c8d to your computer and use it in GitHub Desktop.
Save dnnta/cbd5f809a27508051c8d to your computer and use it in GitHub Desktop.
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