IOS UITableView 表格视图的绝大部分方法

来源:互联网 发布:手机淘宝2016官方版 编辑:程序博客网 时间:2024/05/21 10:03
//初始化一个 表视图
1、- (id)initWithFrame:(CGRect)frame style:(UITableViewStyle)style
初始化一个表视图,区域和类型


//配置表视图
2、- (NSInteger)numberOfRowsInSection:(NSInteger)section
返回表视图分组中的行数
3、- (NSInteger)numberOfSections
返回表中的分组数


//创建表视图单元


4、- (void)registerNib:(UINib *)nib forCellReuseIdentifier:(NSString *)identifier
注册一个包含指定标识表视图的一个行元素的nib对象
5、- (void)registerNib:(UINib *)nib forHeaderFooterViewReuseIdentifier:(NSString *)identifier
注册一个包含页眉或页脚的指定标识表视图的nib对象


6、- (void)registerClass:(Class)cellClass forCellReuseIdentifier:(NSString *)identifier
注册一个类,用来创建新的表单元格
7、- (void)registerClass:(Class)aClass forHeaderFooterViewReuseIdentifier:(NSString *)identifier
注册一个类,用来创建新的包含页眉或页脚的表视图


8、- (id)dequeueReusableCellWithIdentifier:(NSString *)identifier
返回一个指定标识的可重复使用的表视图单元
9、- (id)dequeueReusableCellWithIdentifier:(NSString *)identifier forIndexPath:(NSIndexPath *)indexPath
返回一个指定路径上的指定标识的可重复使用的表视图单元
10、- (id)dequeueReusableHeaderFooterViewWithIdentifier:(NSString *)identifier
返回一个指定标识的可重复使用的附带页眉页脚的视图


11、- (UITableViewHeaderFooterView *)headerViewForSection:(NSInteger)section
返回指定分区的头视图
12、- (UITableViewHeaderFooterView *)footerViewForSection:(NSInteger)section
返回指定分区的脚视图


//滚动表视图


13、- (void)scrollToRowAtIndexPath:(NSIndexPath *)indexPath atScrollPosition:(UITableViewScrollPosition)scrollPosition animated:(BOOL)animated
滚动表内容直到在特定路径indexPath上的一行所在屏幕上的特定位置
14、- (void)scrollToNearestSelectedRowAtScrollPosition:(UITableViewScrollPosition)scrollPosition animated:(BOOL)animated
滚动表视图到选定行最近的位置


//访问单元格和分区


15、– cellForRowAtIndexPath:
返回指定位置上的表单元
16、– indexPathForCell:
返回某个表单元所在的位置
17、– indexPathForRowAtPoint:
返回给定的点所在行的位置
18、– indexPathsForRowsInRect:
返回一个数组,这个数组包含了给定区域内各个行的位置
19、– visibleCells
返回在接受者中可见的表单元
20、– indexPathsForVisibleRows
返回一个数组,这个数组是一个索引,是一个在接收者中所有可识别的可见行的索引


//管理选中的行


21、– indexPathForSelectedRow
返回选中行的索引
22、– indexPathsForSelectedRows
返回由所有选中行的索引所组成的一个数组
23、– selectRowAtIndexPath:animated:scrollPosition:
选中指定IndexPath的行
24、– deselectRowAtIndexPath:animated:
取消选中的指定IndexPath的行




//插入、删除、移动  行和分区


25、– insertRowsAtIndexPaths:withRowAnimation: 
//根据indexPath数组插入行
26、– deleteRowsAtIndexPaths:withRowAnimation: 
//根据indexPath数组删除行
27、– moveRowAtIndexPath:toIndexPath:
 //移动一行到另一行
28、– insertSections:withRowAnimation: //插入分区
29、– deleteSections:withRowAnimation: //删除分区
30、– moveSection:toSection: //移动分区




//载入数据
32、- (void)reloadData
为表重载入数据,这个方法可以载入表中的任何数据
33、– reloadRowsAtIndexPaths:withRowAnimation: 
// 重载部分行数据,不用reload整个表
34、– reloadSections:withRowAnimation: 
// 重载指定分区数据
35、– reloadSectionIndexTitles 

0 0
原创粉丝点击