【问题标题】:iOS alphabetical scroll for UICollectionViewUICollectionView 的 iOS 字母滚动
【发布时间】:2014-06-23 12:15:42
【问题描述】:

我有一个集合视图,其中显示了多个人物及其姓名的图像,并且我已经实现了搜索和排序功能。但是,问题是我也想要按字母顺序排列,但是集合视图没有像 UITableView 这样的委托方法。

- (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,但这会在一个部分中显示集合视图单元格。我不想要多个部分。我只想要部分并实现它的字母滚动功能。

以上方法不在UICollectionViewDelegate方法中。

【问题讨论】:

标签: ios swift uicollectionview


【解决方案1】:

BDKCollectionIndexView 实现了类似UITableView 的部分索引栏。一旦你将它放在屏幕上,它就很容易集成:只需从你的数据源中分配一个 NSStrings 数组:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-12-30
    • 1970-01-01
    • 2015-04-27
    • 1970-01-01
    • 2016-08-07
    • 1970-01-01
    • 2015-07-15
    相关资源
    最近更新 更多