Skip to content

NSIndexPath

NSIndexPath 表示一个由多个索引组成的“路径”。在 UIKit 里最常见的用法是表示表格/集合视图的 sectionrow/item

从单个索引创建路径。

static indexPathWithIndex(index: number): NSIndexPath

Parameters:

NameTypeDescription
indexnumber索引。

Return Value:

  • NSIndexPath: 新路径。

从索引数组与长度创建。

static indexPathWithIndexesLength(indexes: any, length: number): NSIndexPath

Parameters:

NameTypeDescription
indexesany索引序列。
lengthnumber长度。

Return Value:

  • NSIndexPath: 新路径。

创建 TableView 常用的 row/section 路径。

static indexPathForRowInSection(row: number, section: number): NSIndexPath

Parameters:

NameTypeDescription
rownumber行索引。
sectionnumber段索引。

Return Value:

  • NSIndexPath: 新路径。

创建 CollectionView 常用的 item/section 路径。

static indexPathForItemInSection(item: number, section: number): NSIndexPath

Parameters:

NameTypeDescription
itemnumber项索引。
sectionnumber段索引。

Return Value:

  • NSIndexPath: 新路径。

路径中索引个数。

length(): number

Return Value:

  • number: 索引个数。

取指定位置的索引。

indexAtPosition(position: number): number

Parameters:

NameTypeDescription
positionnumber位置。

Return Value:

  • number: 该位置索引。

将索引写入 C 数组。

getIndexes(indexes: any): void

Parameters:

NameTypeDescription
indexesany目标数组。

Return Value:

  • 无。

与另一路径比较。

compare(otherObject: NSIndexPath): number

Parameters:

NameTypeDescription
otherObjectNSIndexPath另一路径。

Return Value:

  • number: 比较结果。

在末尾追加索引得到新路径。

indexPathByAddingIndex(index: number): NSIndexPath

Parameters:

NameTypeDescription
indexnumber要追加的索引。

Return Value:

  • NSIndexPath: 新路径。

移除最后一个索引得到新路径。

indexPathByRemovingLastIndex(): NSIndexPath

Return Value:

  • NSIndexPath: 新路径。
  • UIKit:UITableView / UICollectionView(待补齐)
头文件 API 清单

正在加载…

协议:,来源: