【发布时间】:2017-06-09 12:07:12
【问题描述】:
我在项目中使用了联系人 Book,所有数据显示为 sectionWise.Tableview 部分索引,不显示该实现 sectionForSectionIndexTitle 和 sectionIndexTitlesForTableView 但不调用。
为此,我使用了以下代码:
let arrIndexSection = ["A","B","C","D", "E", "F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
func tableView(_ tableView: UITableView, sectionForSectionIndexTitle title: String, at index: Int) -> Int
{
return ([UITableViewIndexSearch] + UILocalizedIndexedCollation.current().sectionIndexTitles as NSArray).index(of: title) - 1
}
func sectionIndexTitlesForTableView(tableView: UITableView) -> [AnyObject]!
{
return arrIndexSection as [AnyObject]
}
任何人对上述解决方案有想法或解决方案,请帮助我。
谢谢。
【问题讨论】:
-
第二个应该是
func sectionIndexTitles(for tableView: UITableView) -> [String]?