iOS UITableView~datasource(数据源方法)

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

一、UITableView的datasource实现:

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

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

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

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

//回调获取table的section数量

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView

//回调获取table的每个section的header标题

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

//回调获取table的每个section的footer标题

- (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

谢谢!!!

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

友情链接更多精彩内容