shr*_*ani 1 iphone ios swift swift3
我在项目中使用了联系人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]
}
Run Code Online (Sandbox Code Playgroud)
任何人都有上述解决方案的想法或解决方案,请帮助我.
谢谢.
更改以下给出的部分方法
func numberOfSections(in tableView: UITableView) -> Int {
return arrIndexSection.count
}
func sectionIndexTitles(for tableView: UITableView) -> [String]? {
return arrIndexSection
}
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return 44
}
Run Code Online (Sandbox Code Playgroud)
检查以下几点