- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我在项目中使用了联系簿,所有数据显示为 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 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
}
检查以下几点
关于ios - sectionForSectionIndexTitle 和 sectionIndexTitlesForTableView 未在 swift 3 中调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44457427/
我有一个包含许多部分的表格 View ,这些部分的标题只是 A-Z 和 #,就像在 iPhone 通讯录应用程序中一样。我已经实现了sectionIndexTitlesForTableView,可以快
我正在尝试在 sectionIndexTitlesForTableView 中的字母之间添加空格以占用所有屏幕高度。我找到了这个方法: UITableView section index spacin
我需要在 iOS 5 中更改 sectionIndexTitlesForTableView 的颜色。我在 API 中找不到任何方法来完成这项任务。谁能给我一些帮助? sectionIndexTitle
我当前的项目中遇到了这个 super 奇怪的错误。为了了解发生了什么,我将所有内容缩小到最简单的应用程序,可以在此处下载: download simple example here (这里没有自动释放
我有一个表格 View ,我在其中使用 sectionIndexTitlesForTableView 来显示索引。我必须显示位于不同国家/地区的大学列表。每个国家可以有不止一所大学,所以表格显示如下:
我在项目中使用了联系簿,所有数据显示为 sectionWise。Tableview 部分索引不显示该实现 sectionForSectionIndexTitle 和 sectionIndexTitle
这里我在城市明智地显示事件列表,所以在 tableview 的右侧,A 到 Z 字母显示在 tableview 中,但我想更改 A 到 Z 字母的 y 位置(SectionIndexTitle)。我使
我是一名优秀的程序员,十分优秀!