Skip to content

UITableView

UITableView 继承自 UIScrollView,用于展示分组或普通的列表。插件运行时通常通过 dataSource(以及运行时实现的 delegate)提供内容,并通过“注册 → 复用”机制创建 cell。

属性类型说明
stylenumber只读。表格样式。
dataSourceid数据源对象。
rowHeightnumber行高。
separatorStylenumber分割线样式。
separatorColorUIColor | null分割线颜色。
tableHeaderViewUIView | null表头视图。
tableFooterViewUIView | null表尾视图。
backgroundViewUIView | null背景视图。
allowsSelectionboolean是否允许选择。
allowsMultipleSelectionDuringEditingboolean编辑状态下是否允许多选。
editingboolean是否编辑状态。
sectionHeaderHeightnumbersection 头部高度。
sectionFooterHeightnumbersection 底部高度。
方法参数返回值说明
reloadData()void刷新全部数据。
reloadSectionIndexTitles()void刷新 section index 标题。
numberOfSections()numbersection 数量。
numberOfRowsInSection(section)section: numbernumber指定 section 的行数。
rectForSection(section)section: number{ x: number, y: number, width: number, height: number }section 区域。
rectForHeaderInSection(section)section: number{ x: number, y: number, width: number, height: number }section header 区域。
rectForFooterInSection(section)section: number{ x: number, y: number, width: number, height: number }section footer 区域。
rectForRowAtIndexPath(indexPath)indexPath: NSIndexPath{ x: number, y: number, width: number, height: number }行区域。
indexPathForRowAtPoint(point)point: { x: number, y: number }NSIndexPath | null根据点坐标反查行 indexPath。
indexPathForCell(cell)cell: UITableViewCellNSIndexPath | null根据 cell 反查 indexPath。
indexPathsForRowsInRect(rect)rect: { x: number, y: number, width: number, height: number }NSArrayrect 内行的 indexPath 列表。
cellForRowAtIndexPath(indexPath)indexPath: NSIndexPathUITableViewCell | null返回已创建且可见的 cell(不可见则可能为 null)。
visibleCells()NSArray可见 cell 列表。
indexPathsForVisibleRows()NSArray可见行的 indexPath 列表。
headerViewForSection(section)section: numberUIView | null返回 section header view(可见时)。
footerViewForSection(section)section: numberUIView | null返回 section footer view(可见时)。
方法参数返回值说明
scrollToRowAtIndexPathAtScrollPositionAnimated(indexPath, scrollPosition, animated)indexPath: NSIndexPath, scrollPosition: number, animated: booleanvoid滚动到指定行。
scrollToNearestSelectedRowAtScrollPositionAnimated(scrollPosition, animated)scrollPosition: number, animated: booleanvoid滚动到最近的选中行。
方法参数返回值说明
beginUpdates()void开始一组批量更新。
endUpdates()void结束一组批量更新。
insertSectionsWithRowAnimation(sections, animation)sections: NSIndexSet, animation: numbervoid插入 section。
deleteSectionsWithRowAnimation(sections, animation)sections: NSIndexSet, animation: numbervoid删除 section。
reloadSectionsWithRowAnimation(sections, animation)sections: NSIndexSet, animation: numbervoid刷新 section。
moveSectionToSection(section, newSection)section: number, newSection: numbervoid移动 section。
insertRowsAtIndexPathsWithRowAnimation(indexPaths, animation)indexPaths: NSArray, animation: numbervoid插入行。
deleteRowsAtIndexPathsWithRowAnimation(indexPaths, animation)indexPaths: NSArray, animation: numbervoid删除行。
reloadRowsAtIndexPathsWithRowAnimation(indexPaths, animation)indexPaths: NSArray, animation: numbervoid刷新行。
moveRowAtIndexPathToIndexPath(indexPath, newIndexPath)indexPath: NSIndexPath, newIndexPath: NSIndexPathvoid移动行。
方法参数返回值说明
setEditingAnimated(editing, animated)editing: boolean, animated: booleanvoid设置编辑状态(可动画)。
indexPathForSelectedRow()NSIndexPath | null当前选中行(单选场景)。
indexPathsForSelectedRows()NSArray当前选中行列表(多选场景)。
selectRowAtIndexPathAnimatedScrollPosition(indexPath, animated, scrollPosition)indexPath: NSIndexPath, animated: boolean, scrollPosition: numbervoid选中行并可滚动到可见位置。
deselectRowAtIndexPathAnimated(indexPath, animated)indexPath: NSIndexPath, animated: booleanvoid取消选中。
方法参数返回值说明
dequeueReusableCellWithIdentifier(identifier)identifier: stringid按 identifier 取出复用 cell。
dequeueReusableCellWithIdentifierForIndexPath(identifier, indexPath)identifier: string, indexPath: NSIndexPathid按 identifier 与 indexPath 取出复用 cell。
dequeueReusableHeaderFooterViewWithIdentifier(identifier)identifier: stringid取出复用 header/footer view。
registerClassForCellReuseIdentifier(cellClass, identifier)cellClass: id, identifier: stringvoid注册 cell 类型。
registerClassForHeaderFooterViewReuseIdentifier(aClass, identifier)aClass: id, identifier: stringvoid注册 header/footer view 类型。

当前运行时未额外暴露 UITableView 的类成员。

头文件 API 清单

正在加载…

协议:,来源: