转载请声明出处:http://blog.youkuaiyun.com/jinnchang/article/details/45037159
1、前言
当我们的 Table View 中数据量比较大、分段比较多的时候我们可以引入 IndexList 来方便地完成分段的定位,例如系统的通讯录程序。我们可以通过设置 Table View 的 sectionIndexMinimumDisplayRowCount 属性来指定当 Table View 中有多少行的时候开始显示 IndexList,默认的设置是 NSIntegerMax,即默认是不显示 IndexList 的。
为了能够使用 IndexList 我们还需要实现 UITableViewDataSource 中以下两个方法:
// 设置分段索引数组
func sectionIndexTitlesForTableView(tableView: UITableView) -> [AnyObject]!
// 滑动索引触发事件
func tableView(tableView: UITableView, sectionForSectionIndexTitle title: String, atIndex i