UI集合视图,按字母顺序滚动

时间:2016-07-07 00:05:27

标签: ios swift uicollectionview tableview

我正在尝试使用UICollectionView实现按字母顺序排列的滚动列表,我不确定这是否可行,因为我只看到了表视图。目前我看到用于表视图的代码是

这是Swift中的一个简单解决方案,假设您在数组中有标题标题。如果找不到标题,它将返回数组中的先前索引。

func sectionIndexTitlesForTableView(tableView: UITableView) -> [String]? {
return "ABCDEFGHIJKLMNOPQRSTUVWXYZ".characters.flatMap{String($0)}
}

func tableView(tableView: UITableView, sectionForSectionIndexTitle title: String, atIndex index: Int) -> Int {
return self.headerTitles.filter{$0 <= title}.count - 1
}

如何更改此设置以使用集合视图?

1 个答案:

答案 0 :(得分:0)

我知道Collection View也有部分和项目。你只需要垂直滚动。单元格宽度等于屏幕宽度。它看起来像桌子。

相关问题