Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS alphabetical scroll for UICollectionView

I have a collection view which shows multiple images of peoples and their names, and I have implemented search and sorting functionality. However, the problem is I want alphabetical also, but the collection view does not have delegate methods like UITableView has.

- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView {
    return[NSArray arrayWithObjects:@"a", @"e", @"i", @"m", @"p", nil];
}

- (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString
    *)title atIndex:(NSInteger)index {
        return <yourSectionIndexForTheSectionForSectionIndexTitle >;
}

I had tried this question also, but this shows collection view cells in a section. I don't want multiple sections. I want only section and implement alphabetical scroll functionality it.

Above methods are not in UICollectionViewDelegate methods.

like image 990
ShujatAli Avatar asked Jun 23 '14 12:06

ShujatAli


1 Answers

BDKCollectionIndexView implements a UITableView-like section index bar. It's pretty easy to integrate once you have it positioned onscreen: just assign an array of NSStrings from your datasource:

self.indexView.indexTitles = self.fetchResultsController.sectionIndexTitles;
like image 68
jszumski Avatar answered Oct 06 '22 01:10

jszumski