iOS tableview的delegate和datasource执行顺序

来源:互联网 发布:淘宝查排名 编辑:程序博客网 时间:2024/05/29 08:35

前段时间去面试的时候遇到这道题,结果只知道一个大概调用顺序,于是写了一个demo测试了一下,执行这些方法的顺序如下:

1.//有多少列
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView

2.//cell 页眉高度
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section

3.//cell页脚高度
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section

4.//每组有多少行
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

5.//cell高度
-(CGFloat)tableView:(UITableView )tableView heightForRowAtIndexPath:(NSIndexPath )indexPath

6.//布局UItableviewcell
-(UITableViewCell )tableView:(UITableView )tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

原创粉丝点击