Last active
August 29, 2015 14:02
-
-
Save dnnta/cbd5f809a27508051c8d to your computer and use it in GitHub Desktop.
detect which section of UITableview \nFrom http://transoceanic.blogspot.com/2012/08/objective-c-uitableview-detect-which.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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