UITableView回调函数的执行顺序
2015-12-20 20:30
627 查看
UITableView 回调函数调用顺序:
1、
-(NSInteger)numberOfSectionsInTableView:(UITableView
*)tableView
{
//只加载一次。首先加载的就是这个函数。
}
2、
-(CGFloat)tableView:(UITableView*)tableView heightForHeaderInSection:(NSInteger)section
{
//有几个section就会加载几次。
}
3、
-(CGFloat)tableView:(UITableView
*)tableViewheightForFooterInSection:(NSInteger)section
{
//有几个section就会加载几次。
}
4、
-(NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)section
{
//每一个section中的row数量只调用一次。
}
5、
-(CGFloat)tableView:(UITableView *)tableViewheightForRowAtIndexPath:(NSIndexPath *)indexPath
{
//有多少个row就会调用多少次这个函数。
}
6、
-(UITableViewCell*)tableView:(UITableView *)tableViewcellForRowAtIndexPath:(NSIndexPath *)indexPath
{
//其中6和7交替调用。就是每加载完一个Cell就会调用一次7,7调用结束之后有开始加载6。直到把tableView中的所有cell全部加载完成后,6和7才结束。
}
7、
- (BOOL)tableView:(UITableView *)tableViewcanEditRowAtIndexPath:(NSIndexPath *)indexPath
{
//和6交替调用。
}
8、
-(UIView*)tableView:(UITableView *)tableViewviewForHeaderInSection:(NSInteger)section
{
//当所有的Cell加载完后,调用这个函数。有多少个section(Header+ Footer),就会调用多少次该函数。
}
总结:首先调用section(row)的个数,然后调用section(row)的高度,最后加载内容(先加载row,后加载section)。
对于一些动作函数(例如点击、移动、删除),当动作发生时调用这些函数。
来自 <http://blog.sina.com.cn/s/blog_c1279bc90101b0t6.html>
1、
-(NSInteger)numberOfSectionsInTableView:(UITableView
*)tableView
{
//只加载一次。首先加载的就是这个函数。
}
2、
-(CGFloat)tableView:(UITableView*)tableView heightForHeaderInSection:(NSInteger)section
{
//有几个section就会加载几次。
}
3、
-(CGFloat)tableView:(UITableView
*)tableViewheightForFooterInSection:(NSInteger)section
{
//有几个section就会加载几次。
}
4、
-(NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)section
{
//每一个section中的row数量只调用一次。
}
5、
-(CGFloat)tableView:(UITableView *)tableViewheightForRowAtIndexPath:(NSIndexPath *)indexPath
{
//有多少个row就会调用多少次这个函数。
}
6、
-(UITableViewCell*)tableView:(UITableView *)tableViewcellForRowAtIndexPath:(NSIndexPath *)indexPath
{
//其中6和7交替调用。就是每加载完一个Cell就会调用一次7,7调用结束之后有开始加载6。直到把tableView中的所有cell全部加载完成后,6和7才结束。
}
7、
- (BOOL)tableView:(UITableView *)tableViewcanEditRowAtIndexPath:(NSIndexPath *)indexPath
{
//和6交替调用。
}
8、
-(UIView*)tableView:(UITableView *)tableViewviewForHeaderInSection:(NSInteger)section
{
//当所有的Cell加载完后,调用这个函数。有多少个section(Header+ Footer),就会调用多少次该函数。
}
总结:首先调用section(row)的个数,然后调用section(row)的高度,最后加载内容(先加载row,后加载section)。
对于一些动作函数(例如点击、移动、删除),当动作发生时调用这些函数。
来自 <http://blog.sina.com.cn/s/blog_c1279bc90101b0t6.html>
相关文章推荐
- karma requirejs 加载问题小记
- android 展示单选列表对话框 builder.setSingleChoiceItems
- hdu 4836 The Query on the Tree(线段树or树状数组)
- UI布局画分割线
- UESTC 482 Charitable Exchange(四川省赛B题)
- 为什么Java中1000==1000为false而100==100为true?(Integer)
- 第1章 使用视图UI组件
- 使用Roboguice依赖注入规划Android项目
- iOS开发——UISearchController实现搜索栏功能|阳和移动开发
- UESTC 1272 Final Pan's prime numbers 猜答案、乱搞题、数论
- UITableViewCell中如何添加图片数组
- UESTC 1269 ZhangYu Speech 预处理、前缀和
- 区别linq查询中的IEnumerable<T>和IQueryable<T>
- 绑定UI使用说明
- php判断mysql_query是否成功执行
- ios build时,Undefined symbols for architecture xxx问题的总结
- 造轮子_MVC+EF(CodeFirst)+Easyui医药MIS系统
- 【APUE】7、signal函数
- UITabelViewCell高度的自适应
- [LeetCode] 303. Range Sum Query - Immutable (Easy)