我有一个集合 View ,其中显示了人物及其姓名的多个图像,并且已经实现了搜索和排序功能。但是,问题是我也想按字母顺序排列,但是集合 View 没有像UITableView
那样的委托(delegate)方法。
- (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 >;
}
我也尝试过此question,但这在一节中显示了集合 View 单元格。我不要多个部分。我只需要一节并实现按字母顺序滚动的功能。上面的方法不在
UICollectionViewDelegate
方法中。 最佳答案
BDKCollectionIndexView
实现类似于UITableView
的部分索引栏。一旦将其放置在屏幕上,集成起来就非常容易:只需从数据源分配一个NSString
数组:
self.indexView.indexTitles = self.fetchResultsController.sectionIndexTitles;
关于UICollectionView的iOS字母滚动,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/24365701/