Created
April 19, 2013 14:10
-
-
Save arisro/5420595 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// dataArray is the nsdictionary/array containing you list of names; we take the 1st letter of each, and compare it with the title of the Index the user "clicked" on | |
// we cycle through all your names until we find a name starting with the letter that he touched in the index. When we found the name, we scroll the table tot that row. | |
- (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index { | |
for (int i = 0; i< [dataArray count]; i++) { | |
NSString *letterString = [[dataArray objectAtIndex:i] substringToIndex:1]; | |
if ([letterString isEqualToString:title]) { | |
[tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:i inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:YES]; | |
break; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment