Created
September 28, 2013 16:57
-
-
Save Tricertops/6744074 to your computer and use it in GitHub Desktop.
Animated scrolling for table view section index.
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
| - (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index { | |
| NSUInteger section = ... | |
| CGRect rect = [self.tableView rectForSection:section]; | |
| // Include content inset | |
| rect.origin.y -= self.tableView.contentInset.top; | |
| // Restore previous offset and animate to destination | |
| CGPoint offset = self.tableView.contentOffset; | |
| [[NSOperationQueue mainQueue] asynchronous:^{ | |
| self.tableView.contentOffset = offset; | |
| [self.tableView setContentOffset:rect.origin animated:YES]; | |
| }]; | |
| return section; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment