iOS UITableView~datasource(数据源方法)

来源:互联网 发布:淘宝店开店流程 编辑:程序博客网 时间:2024/06/06 01:09

//联系人:石虎  QQ: 1224614774昵称:嗡嘛呢叭咪哄

一、UITableViewdatasource实现:

//回调获取每个section中的cell的行数

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section


//回调获取每个uitableviewcell,只有当需要显示的celltable的可视区域内才被回调

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath


//回调获取tablesection数量

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView


//回调获取table的每个sectionheader标题

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section


//回调获取table的每个sectionfooter标题

- (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section


//回调判断指定的cell是否能有编辑状态

- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath


//回调判断指定的cell能否被移动当进入编辑模式的时候

- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath


//回调获取table右边的索引栏内容

- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView


//当点击右边索引栏时执行的回调,可以根据点击的title值返回应该跳到第几个section

- (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index


//当所有相关编辑模式的回调,只实现该回调时默认能滑动cell出现删除按钮。当和其他相关的编辑模式回调混合使用分别有移动,插入,删除等功能

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath


//当进入的是移动的编辑模式时,实现该回调进行移动cell和数据的更新

- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath


谢谢!!!


原创粉丝点击