简体   繁体   中英

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.

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 NSString s from your datasource:

self.indexView.indexTitles = self.fetchResultsController.sectionIndexTitles;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM