簡體   English   中英

UICollectionView 的 iOS 字母滾動

[英]iOS alphabetical scroll for UICollectionView

我有一個集合視圖,它顯示了多個人及其姓名的圖像,並且我已經實現了搜索和排序功能。 但是,問題是我也想要按字母順序排列,但是集合視圖沒有像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 >;
}

我也試過這個問題,但這顯示了一個部分中的集合視圖單元格。 我不想要多個部分。 我只想要部分並實現按字母順序滾動的功能。

以上方法不在UICollectionViewDelegate方法中。

BDKCollectionIndexView實現了一個類似UITableView的部分索引欄。 一旦你將它定位在屏幕上,它就很容易集成:只需從你的數據源分配一個NSString數組:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM