IOS alphabetical scroll for uicollectionview

2019-04-06 09:32发布

问题:

I had a collectionview which shows multiple images of peoples and their names , i had implemented search and sorting functionality , but problem is i want alphabetical also . but it collectionview does not have delegate methods like table 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 collectionview cells in a section. but problem is i dont want multiple sections. i want only section and implement alphabetical scroll functionality it , please guide me some help

above methods are not in collectionviewdelegate methods.

回答1:

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;