UITableView 基础篇

   属性:

   rowHeight:行高

   sectionHeaderHeight:表头高度

   sectionFooterHeight:表尾高度

   estimatedRowHeight:估记高度 (iOS7)

   estimatedSectionHeaderHeight:估计表头高度(iOS7)

   estimatedSectionFooterHeight:估计表尾高度 (iOS7)

   separatorInset:分割线设置 (iOS7)

   backgroundView:背景视图

   numberOfSections:表格包含多少个部分

   visibleCells:显示的单元格 (取值为NSArray)

   indexPathsForVisibleRows:可见单元的的索引  (取值为NSArray)

   editing:是否允许编辑

   allowsSelection:是否允许选中

   allowsSelectionDuringEditing:是否能够在编辑状态下选中

   allowsMultipleSelection:是否允许多选

   allowsMultipleSelectionDuringEditing:是否允许在编辑状态下多选

   indexPathForSelectedRow:选中单元的的索引 (单个)

   indexPathsForSelectedRows:选中的单元格的索引 (单个或者多个 取值为NSArray)

   sectionIndexMinimumDisplayRowCount:设置当表头有多少个的时候显示表头索引 (取值为 NSInteger)

   sectionIndexColor:选中的某个单元格的文本颜色

   sectionIndexBackgroundColor:选中的某个单元格的背景颜色 (iOS7)

   sectionIndexTrackingBackgroundColor:选择某个部分的单元格的持续背景颜色

   separatorStyle:分割线形式      (UITableViewCellSeparatorStyleNone,UITableViewCellSeparatorStyleSingleLine,UITableViewCellSeparatorStyleSingleLineEtched )

   separatorColor:分割线颜色

   separatorEffect:分割线效果 (ios 8)

   cellLayoutMarginsFollowReadableWidth :是否对风格线内容留白 (iOS9加入主要针对ipad)

   tableHeaderView:表头视图

   tableFooterView:表尾视图

   remembersLastFocusedIndexPath :?

   方法:

   - (instancetype)initWithFrame:(CGRect)frame style:(UITableViewStyle)style;初始化方法同时设置表格模式

   - (void)reloadData;刷新数据

   - (void)reloadSectionIndexTitles;刷新索引

   - (NSInteger)numberOfRowsInSection:(NSInteger)section;获取某个组中的有多少行

   - (CGRect)rectForSection:(NSInteger)section;获取某个租的位置大小

   - (CGRect)rectForHeaderInSection:(NSInteger)section;获取表头的位置大小
   - (CGRect)rectForFooterInSection:(NSInteger)section;获取表尾的位置大小
   - (CGRect)rectForRowAtIndexPath:(NSIndexPath *)indexPath;获取单元格的位置大小

   - (nullable NSIndexPath *)indexPathForRowAtPoint:(CGPoint)point;点击某个点获取改点所在的单元格的索引

   - (nullable NSIndexPath *)indexPathForCell:(UITableViewCell *)cell;获取单元格索引

   - (nullable NSArray<NSIndexPath *> *)indexPathsForRowsInRect:(CGRect)rect;zai'mou'g区域里面返回多个单元格的信息

   - (nullable __kindof UITableViewCell *)cellForRowAtIndexPath:(NSIndexPath *)indexPath;通过单元格索引获取单元格

   - (nullable UITableViewHeaderFooterView *)headerViewForSection:(NSInteger)section;设置表头视图
   - (nullable UITableViewHeaderFooterView *)footerViewForSection:(NSInteger)section;设置表尾视图

   - (void)scrollToRowAtIndexPath:(NSIndexPath *)indexPath atScrollPosition:(UITableViewScrollPosition)scrollPosition animated:(BOOL)animated;表视图定位到某一行
   - (void)scrollToNearestSelectedRowAtScrollPosition:(UITableViewScrollPosition)scrollPosition animated:(BOOL)animated;表视图定位到选中行

   - (void)beginUpdates;只添加或删除才会更新行数
   - (void)endUpdates;添加或删除后会调用添加或删除方法时才会更新

   - (void)insertSections:(NSIndexSet *)sections withRowAnimation:(UITableViewRowAnimation)animation;插入一个或者多个组并是否使用动画
   - (void)deleteSections:(NSIndexSet *)sections withRowAnimation:(UITableViewRowAnimation)animation;删除一个或者多个组并使用动画
   - (void)reloadSections:(NSIndexSet *)sections withRowAnimation:(UITableViewRowAnimation)animation;更新一个或者多个组并使用动画
   - (void)moveSection:(NSInteger)section toSection:(NSInteger)newSection ;移动某个组到目标组
   - (void)insertRowsAtIndexPaths:(NSArray<NSIndexPath *> *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation;插入一个或者多个单元格并使用动画
   - (void)deleteRowsAtIndexPaths:(NSArray<NSIndexPath *> *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation;删除一个或者多个单元格并使用动画
   - (void)reloadRowsAtIndexPaths:(NSArray<NSIndexPath *> *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation更新单元格并使用动画
   - (void)moveRowAtIndexPath:(NSIndexPath *)indexPath toIndexPath:(NSIndexPath *)newIndexPath移动单元格到某个目标单元格

   - (void)setEditing:(BOOL)editing animated:(BOOL)animated;进入编辑状态同时设定是否使用动画

   - (void)selectRowAtIndexPath:(nullable NSIndexPath *)indexPath animated:(BOOL)animated scrollPosition:(UITableViewScrollPosition)scrollPosition;设置选中某个区域的单元格
   - (void)deselectRowAtIndexPath:(NSIndexPath *)indexPath animated:(BOOL)animated;取消选中的单元格

   - (nullable __kindof UITableViewCell *)dequeueReusableCellWithIdentifier:(NSString *)identifier;  获取重用队列里面的单元格

   - (__kindof UITableViewCell *)dequeueReusableCellWithIdentifier:(NSString *)identifier forIndexPath:(NSIndexPath *)indexPath;根据索引取出某行单元格复用

   - (nullable __kindof UITableViewHeaderFooterView *)dequeueReusableHeaderFooterViewWithIdentifier:(NSString *)identifier;设置队列中的重用单元格的标识符

   数据代理:

  - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section; 设置表格行数

  - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;设置单元格的显示内容

  - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView;设置表格组数

  - (nullable NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section;指定表格中指定某个组头的标题

  - (nullable NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section;指定表格中指定某个组尾的标题

  - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath;设置单元格是否能够编辑

  - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath;设置单元格是否能够移动

  - (nullable NSArray<NSString *> *)sectionIndexTitlesForTableView:(UITableView *)tableView;右边索引的标题

  - (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index;点击右边索引的时候调用的方法

  - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath;编辑单元格

  - (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath;移动单元格

  代理:

  - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath;单元格将要显示
  - (void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInteger)section;组头视图将要显示
  - (void)tableView:(UITableView *)tableView willDisplayFooterView:(UIView *)view forSection:(NSInteger)section;组表尾将要显示
  - (void)tableView:(UITableView *)tableView didEndDisplayingCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath*)indexPath;单元格已经显示
  - (void)tableView:(UITableView *)tableView didEndDisplayingHeaderView:(UIView *)view forSection:(NSInteger)section;组头视图已经显示
  - (void)tableView:(UITableView *)tableView didEndDisplayingFooterView:(UIView *)view forSection:(NSInteger)section;组表尾已经显示

  - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;单元格高度
  - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section;表头高度
  - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section;表尾高度
  - (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath;估计单元格高度
  - (CGFloat)tableView:(UITableView *)tableView estimatedHeightForHeaderInSection:(NSInteger)section;估计表头高度 (ios7)
  - (CGFloat)tableView:(UITableView *)tableView estimatedHeightForFooterInSection:(NSInteger)section;估计表尾高度( ios7)
  - (nullable UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section;   设置表头视图(ios7)
  - (nullable UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section;   设置表尾视图
  - (UITableViewCellAccessoryType)tableView:(UITableView *)tableView accessoryTypeForRowWithIndexPath:(NSIndexPath *)indexPath;设置某个单元格的右边的形式
  - (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath;某个单元格右侧按钮的响应方法
  - (BOOL)tableView:(UITableView *)tableView shouldHighlightRowAtIndexPath:(NSIndexPath *)indexPath; 点击状态是否显示高亮
  - (void)tableView:(UITableView *)tableView didHighlightRowAtIndexPath:(NSIndexPath *)indexPath ;单元格高亮状态调用的方法
  - (void)tableView:(UITableView *)tableView didUnhighlightRowAtIndexPath:(NSIndexPath *)indexPath;单元格不是高亮状态执行的方法
  - (nullable NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath;将要选中单元格执行的方法
  - (nullable NSIndexPath *)tableView:(UITableView *)tableView willDeselectRowAtIndexPath:(NSIndexPath *)indexPath;将要取消选中执行的方法
  - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath;选中单元格执行的方法
  - (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath;取消选择单元格执行的方法
  - (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath;可编辑按单元格的编辑形式
  - (nullable NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath;单元格删除移动修改按钮上面的文字
  - (nullable NSArray<UITableViewRowAction *> *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath ;侧滑显示更多交互按钮(ios8_0)
  - (BOOL)tableView:(UITableView *)tableView shouldIndentWhileEditingRowAtIndexPath:(NSIndexPath *)indexPath;进入编辑状态的时候单元格不缩进
  - (void)tableView:(UITableView*)tableView willBeginEditingRowAtIndexPath:(NSIndexPath *)indexPath;将要进入编辑状态的时候执行
  - (void)tableView:(UITableView*)tableView didEndEditingRowAtIndexPath:(NSIndexPath *)indexPath 结束编辑状态的时候执行;
  - (NSIndexPath *)tableView:(UITableView *)tableView targetIndexPathForMoveFromRowAtIndexPath:(NSIndexPath *)sourceIndexPath toProposedIndexPath:(NSIndexPath *)proposedDestinationIndexPath;当前划过的cell位置是否可以被替换,如果不行则给出建议的位置         
  - (NSInteger)tableView:(UITableView *)tableView indentationLevelForRowAtIndexPath:(NSIndexPath *)indexPath;行缩进
  - (BOOL)tableView:(UITableView *)tableView shouldShowMenuForRowAtIndexPath:(NSIndexPath *)indexPath;是否允许显示长按诗的mune菜单
  - (BOOL)tableView:(UITableView *)tableView canPerformAction:(SEL)action forRowAtIndexPath:(NSIndexPath *)indexPath withSender:(nullable id)sender;是否每个单元格都能在长按的时候显示mune菜单
  - (void)tableView:(UITableView *)tableView performAction:(SEL)action forRowAtIndexPath:(NSIndexPath *)indexPath withSender:(nullable id)sender;对一个给定的行告诉代表执行复制或粘贴操作内容,
  - (BOOL)tableView:(UITableView *)tableView canFocusRowAtIndexPath:(NSIndexPath *)indexPath(ios9);
  - (BOOL)tableView:(UITableView *)tableView shouldUpdateFocusInContext:(UITableViewFocusUpdateContext *)(ios9);
  - (void)tableView:(UITableView *)tableView didUpdateFocusInContext:(UITableViewFocusUpdateContext *)context withAnimationCoordinator:(UIFocusAnimationCoordinator *)coordinator(ios9);
  - (nullable NSIndexPath *)indexPathForPreferredFocusedViewInTableView:(UITableView *)tableView(ios9);


   

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值