【发布时间】:2015-03-10 13:10:48
【问题描述】:
是否可以(或不可能)为没有任何节的表编制索引?
【问题讨论】:
-
您可以将
numberOfRowsInSection和numberOfSectionsInTableView的返回值交换,并在其他地方使用[indexPath.section]而不是indexPath.row?
标签: ios uitableview swift indexing
是否可以(或不可能)为没有任何节的表编制索引?
【问题讨论】:
numberOfRowsInSection 和numberOfSectionsInTableView 的返回值交换,并在其他地方使用[indexPath.section] 而不是indexPath.row?
标签: ios uitableview swift indexing
据我所知,除了语法之外,swift 没有任何变化:
/* section headers
appear above each `UITableView` section */
override func tableView(tableView: UITableView,
titleForHeaderInSection section: Int)
-> String {
// do not display empty `Section`s
if !self.sections[section].users.isEmpty {
return self.collation.sectionTitles[section] as String
}
return ""
}
/* section index titles
displayed to the right of the `UITableView` */
override func sectionIndexTitlesForTableView(tableView: UITableView)
-> [AnyObject] {
return self.collation.sectionIndexTitles
}
override func tableView(tableView: UITableView,
sectionForSectionIndexTitle title: String,
atIndex index: Int)
-> Int {
return self.collation.sectionForSectionIndexTitleAtIndex(index)
}
【讨论】: