您的位置:首页 > 产品设计 > UI/UE

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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: