IOS UITableview代理方法总结
tableview的datasource代理
@required的两个数据源方法
1、返回每个 session 中 cell 的个数
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;
2、创建tableviewCell(注意复用)
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
@optional
1、返回session(分组)的个数
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView;
2、设置对应分组的headerView
- (nullable NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section;
3、设置对应分组的额footerview
- (nullable NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section;
------------------------------------Editing------------------------------------
4、设置某个cell是否可以编辑
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath;
5、设置cell是否可以移动
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath;
6、设置tableview的右侧索引
- (nullable NSArray<NSString *> *)sectionIndexTitlesForTableView:(UITableView *)tableView __TVOS_PROHIBITED;
7、点击索引跳转到对应的session分组
- (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index __TVOS_PROHIBITED;
8、处理提交对应编辑状态的数据变化
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath;
9、处理移动cell的数据变化
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath;
------------------------------------UITableViewDelegate------------------------------------
1、处理显示
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath;
- (void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInteger)section NS_AVAILABLE_IOS(6_0);
- (void)tableView:(UITableView *)tableView willDisplayFooterView:(UIView *)view forSection:(NSInteger)section NS_AVAILABLE_IOS(6_0);
- (void)tableView:(UITableView *)tableView didEndDisplayingCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath*)indexPath NS_AVAILABLE_IOS(6_0);
- (void)tableView:(UITableView *)tableView didEndDisplayingHeaderView:(UIView *)view forSection:(NSInteger)section NS_AVAILABLE_IOS(6_0);
- (void)tableView:(UITableView *)tableView didEndDisplayingFooterView:(UIView *)view forSection:(NSInteger)section NS_AVAILABLE_IOS(6_0);
2、设置高度
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section;
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section;
3、预算高度(用预算高度的方法可以快速实现tableview的预加载,如果这些预算方法实现了则上边计算高度的方法会被推迟到view即将显示的时候,因此一些比较复杂的逻辑可以放到这里预算)
- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath NS_AVAILABLE_IOS(7_0);
- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForHeaderInSection:(NSInteger)section NS_AVAILABLE_IOS(7_0);
- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForFooterInSection:(NSInteger)section NS_AVAILABLE_IOS(7_0);
4、自定义session的headerview和footerview
- (nullable UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section;
- (nullable UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section;
5、设置右侧辅助按钮种类和点击方法
- (UITableViewCellAccessoryType)tableView:(UITableView *)tableView accessoryTypeForRowWithIndexPath:(NSIndexPath *)indexPath NS_DEPRECATED_IOS(2_0, 3_0) __TVOS_PROHIBITED;
- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath;
6、tableviewcell被选中时是否高亮
- (BOOL)tableView:(UITableView *)tableView shouldHighlightRowAtIndexPath:(NSIndexPath *)indexPath NS_AVAILABLE_IOS(6_0);
- (void)tableView:(UITableView *)tableView didHighlightRowAtIndexPath:(NSIndexPath *)indexPath NS_AVAILABLE_IOS(6_0);
- (void)tableView:(UITableView *)tableView didUnhighlightRowAtIndexPath:(NSIndexPath *)indexPath NS_AVAILABLE_IOS(6_0);
7、tableviewcell的选中和反选
- (nullable NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath;
- (nullable NSIndexPath *)tableView:(UITableView *)tableView willDeselectRowAtIndexPath:(NSIndexPath *)indexPath NS_AVAILABLE_IOS(3_0);
// Called after the user changes the selection.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath;
- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath NS_AVAILABLE_IOS(3_0);
8、设置左侧编辑状态的按钮种类(默认删除)
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath;
9、设置编辑状态左滑出现的删除按钮的标题
- (nullable NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath NS_AVAILABLE_IOS(3_0) __TVOS_PROHIBITED;
10、自定义编辑状态左滑出现的按钮(返回类型UITableViewRowAction,点击方法是block实现的)
- (nullable NSArray<UITableViewRowAction *> *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath NS_AVAILABLE_IOS(8_0) __TVOS_PROHIBITED;
11、编辑状态cell左侧缩进开关
- (BOOL)tableView:(UITableView *)tableView shouldIndentWhileEditingRowAtIndexPath:(NSIndexPath *)indexPath;
12、开始和结束编辑某个
- (void)tableView:(UITableView*)tableView willBeginEditingRowAtIndexPath:(NSIndexPath *)indexPath __TVOS_PROHIBITED;
- (void)tableView:(UITableView*)tableView didEndEditingRowAtIndexPath:(NSIndexPath *)indexPath __TVOS_PROHIBITED;
13、从一个位置移动到另一个位置
- (NSIndexPath *)tableView:(UITableView *)tableView targetIndexPathForMoveFromRowAtIndexPath:(NSIndexPath *)sourceIndexPath toProposedIndexPath:(NSIndexPath *)proposedDestinationIndexPath;
14、cell缩进
- (NSInteger)tableView:(UITableView *)tableView indentationLevelForRowAtIndexPath:(NSIndexPath *)indexPath;
15、未用过的方法(待验证)
// Copy/Paste. All three methods must be implemented by the delegate. - (BOOL)tableView:(UITableView *)tableView shouldShowMenuForRowAtIndexPath:(NSIndexPath *)indexPath NS_AVAILABLE_IOS(5_0);
- (BOOL)tableView:(UITableView *)tableView canPerformAction:(SEL)action forRowAtIndexPath:(NSIndexPath *)indexPath withSender:(nullable id)sender NS_AVAILABLE_IOS(5_0);
- (void)tableView:(UITableView *)tableView performAction:(SEL)action forRowAtIndexPath:(NSIndexPath *)indexPath withSender:(nullable id)sender NS_AVAILABLE_IOS(5_0); #ifndef SDK_HIDE_TIDE
// Focus - (BOOL)tableView:(UITableView *)tableView canFocusRowAtIndexPath:(NSIndexPath *)indexPath NS_AVAILABLE_IOS(9_0);
- (BOOL)tableView:(UITableView *)tableView shouldUpdateFocusInContext:(UITableViewFocusUpdateContext *)context NS_AVAILABLE_IOS(9_0);
- (void)tableView:(UITableView *)tableView didUpdateFocusInContext:(UITableViewFocusUpdateContext *)context withAnimationCoordinator:(UIFocusAnimationCoordinator *)coordinator NS_AVAILABLE_IOS(9_0);
- (nullable NSIndexPath *)indexPathForPreferredFocusedViewInTableView:(UITableView *)tableView NS_AVAILABLE_IOS(9_0);
IOS UITableview代理方法总结的更多相关文章
- UITableView表格视图、UITableView代理方法及应用
一.基本知识点 UITableView表格视图,是一个可以滚动的界面(理解为垂直滚动的UIScrollView),可展示多行数据,没有行数的限制,只能有一列. 使用UITableView: 1.展示信 ...
- 【转】iOS UITableView的方法解析
原文网址:http://www.cnblogs.com/wfwenchao/articles/3718742.html - (void)viewDidLoad { [super viewDidLoad ...
- iOS UIScrollview代理方法
方法&&属性: // 监控目前滚动的位置(默认CGPointZero) CGPoint contentOffset; - (void)setContentOffset:(CGPoint ...
- IOS UIScrollView常用代理方法
iOS UIScrollView代理方法有很多,从头文件中找出来学习一下 //只要滚动了就会触发 - (void)scrollViewDidScroll:(UIScrollView *)scrollV ...
- iOS UITableView的分割线短15像素,移动到最左边的方法(iOS8)
有好几个朋友问我ios 分割线端了一些 如何解决,于是我就写一篇博客吧.为什么我说是少了15像素呢?首先我们拖拽一个默认的tableview 控件! 看下xcode5 面板的inspector(检查器 ...
- iOS开发之巧用Block和代理方法结合来传值
好久没写技术博客了,因为996的工作周期已经持续好几个月了.每天晚上回家都没有太多精力学习很多其他的东西,而且很多时候是接着完善工作的项目的模块开发.所以博客停歇了这么久,更新率也低了不少,今天补充一 ...
- UITableView的常用属性和代理方法
以下是近期总结的关于tableView的一些属性和代理方法,以及一些常见的问题,现汇总如下,今后还会持续更新,请继续关注: tableView 的头部和尾部视图属性: UISwitch *foot ...
- iOS开发——网络篇——NSURLSession,下载、上传代理方法,利用NSURLSession断点下载,AFN基本使用,网络检测,NSURLConnection补充
一.NSURLConnection补充 前面提到的NSURLConnection有些知识点需要补充 NSURLConnectionDataDelegate的代理方法有一下几个 - (void)conn ...
- IOS中tableView每组的头部控件、通过tableView的代理方法控制某一行的cell能否达到高亮选中状态
一.tableView每组的头部控件 1.控件宽度默认就是tableView的宽度 2.控件高度由下面的代理方法决定 - (CGFloat)tableView:(UITableView *)table ...
随机推荐
- hibernate学习(9)——日志,一对一,二级缓存
1.Hibernate中的日志 1 slf4j 核心jar : slf4j-api-1.6.1.jar .slf4j是日志框架,将其他优秀的日志第三方进行整合. 整合导入jar包 log4j 核心 ...
- frag General URL components
HTTP: The Definitive Guide 2.2.7 Fragments Some resource types, such as HTML, can be divided further ...
- JavaScript的3大组成部分&&ECMAScript函数&&闭包
1.JavaScript实现是由ECMAScript.DOM和BOM组成.a.ECMAScript仅仅是一个描述,定义了脚本语言的所有属性.方法和对象.b.DOM[文档对象模型]是HTML和XML的应 ...
- iscoll制作顶部可以左右滑动的tab
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name ...
- ORA-29275: partial multibyte character
查询表报错 修改方式1 和字符集存储方式有关系 ,修改客户端和服务器的字符集存储方害死 修改方式2 修改表的字段由nvarchar2修改为varchar2
- Karma+Jasmine实现自动化单元测试
1.Karma介绍 Karma是Testacular的新名字,在2012年google开源了Testacular,2013年Testacular改名为Karma.Karma是一个让人感到非常神秘的名字 ...
- C#面试(2016年4月)
1.WebForm和MVC的区别 MVC: 1)通过model.view.controller将处理后台逻辑代码与前台展示逻辑代码进行了很好的分离: 2)通过修改路由规则,可以控制生成自定义的url, ...
- varsh4.1 安装清除cache
yum install automake autoconf ncurses-devel libxslt groff pkgconfig python-docutils readline-devel - ...
- JSP 登录与注册的小案例
源代码连接地址如下:链接:http://pan.baidu.com/s/1nvEuHBj 密码:qsr1 #properties文件 driver=oracle.jdbc.driver.OracleD ...
- https 与http 的坑
网页报这种错误: (blocked:mixed-content) 使用了https就不能夹生http jquery.min.js:4Mixed Content: The page at ' ...