bra*_*ipt 1 uitableview ios swift
我在tableView(第1部分)中有一段行,我需要[NSIndexPath]
为该部分中的所有行初始化一个数组.
我知道我可以很容易地计算该部分中的行数:
let rowsInSection = tableView.numberOfRowsInSection(1)
Run Code Online (Sandbox Code Playgroud)
但这只能得到行数,而不是索引路径.
检索索引路径的最干净,最"类似Swift"的方法是什么?
我正在寻找的一个例子:
func indexPathsForRowsInSection(section: Int) -> [NSIndexPath] {
// magic happens here
return indexPathsForRowsInSection
}
Run Code Online (Sandbox Code Playgroud)
像Swift 3中的这样:
func indexPathsForRowsInSection(_ section: Int, numberOfRows: Int) -> [NSIndexPath] {
return (0..<numberOfRows).map{NSIndexPath(row: $0, section: section)}
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
3908 次 |
最近记录: |