UITableViewDelegate Protocol Reference
Configuring Rows for the Table View //配置table的列表
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath //告诉委托指定cell的高度 - (NSInteger)tableView:(UITableView *)tableView indentationLevelForRowAtIndexPath:(NSIndexPath *)indexPath //告诉委托指定cell的缩进等级 - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath //告诉委托如何渲染cell,cell的背景等样式可以在此设置
Managing Accessory Views //管理附属图标
- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath //当点击cell旁附属图标将触发该方法
Managing Selections //管理被选项
- (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath //当cell将被选择时触发,返回nil可阻止当前cell被选中 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath //当cell被选择时触发(变蓝后) - (NSIndexPath *)tableView:(UITableView *)tableView willDeselectRowAtIndexPath:(NSIndexPath *)indexPath //将被取消选择时触发 - (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath //被取消选择时触发
Modifying the Header and Footer of Sections //改变section的header和footer
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section //为section设置自定义header,需先设置tableView:heightForHeaderInSection: - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section //为section设置自定义footer - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section //设置section的header高度 - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section //设置section的footer高度 - (void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInteger)section //设置header视图如何显示,ios6 - (void)tableView:(UITableView *)tableView willDisplayFooterView:(UIView *)view forSection:(NSInteger)section //设置footer视图如何显示,ios6
Editing Table Rows //编辑行
- (void)tableView:(UITableView *)tableView willBeginEditingRowAtIndexPath:(NSIndexPath *)indexPath //将进入编辑模式(通过横扫等方式) - (void)tableView:(UITableView *)tableView didEndEditingRowAtIndexPath:(NSIndexPath *)indexPath //将结束编辑模式 - (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath //设置图标是删除还是增加,默认为删除 - (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath //修改删除按钮文字 - (BOOL)tableView:(UITableView *)tableView shouldIndentWhileEditingRowAtIndexPath:(NSIndexPath *)indexPath //设置进入编辑状态时,Cell是否缩进,默认为YES缩进
Reordering Table Rows //重排表列表
- (NSIndexPath *)tableView:(UITableView *)tableView targetIndexPathForMoveFromRowAtIndexPath:(NSIndexPath *)sourceIndexPath toProposedIndexPath:(NSIndexPath *)proposedDestinationIndexPath //当row移动时触发
Tracking the Removal of Views //追踪移除视图
- (void)tableView:(UITableView *)tableView didEndDisplayingCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath //当cell被移除时触发,ios6 - (void)tableView:(UITableView *)tableView didEndDisplayingHeaderView:(UIView *)view forSection:(NSInteger)section //当header被移除时触发,ios6 - (void)tableView:(UITableView *)tableView didEndDisplayingFooterView:(UIView *)view forSection:(NSInteger)section //当footer被移除时触发,ios6
Copying and Pasting Row Content //复制和粘贴表内容
- (BOOL)tableView:(UITableView *)tableView shouldShowMenuForRowAtIndexPath:(NSIndexPath *)indexPath //当长按时是否触发复制粘贴菜单,默认为NO - (BOOL)tableView:(UITableView *)tableView canPerformAction:(SEL)action forRowAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender //省略复制和粘贴按钮 - (void)tableView:(UITableView *)tableView performAction:(SEL)action forRowAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender //当用户点击复制和粘贴按钮时触发该委托,action为复制或粘贴操作
Managing Table View Highlighting //管理高亮
- (BOOL)tableView:(UITableView *)tableView shouldHighlightRowAtIndexPath:(NSIndexPath *)indexPath //告诉委托指定row是否支持高亮,YES是支持,ios6 - (void)tableView:(UITableView *)tableView didHighlightRowAtIndexPath:(NSIndexPath *)indexPath //当高亮时触发该委托,ios6 - (void)tableView:(UITableView *)tableView didUnhighlightRowAtIndexPath:(NSIndexPath *)indexPath //当高亮消失时触发该委托,ios6
分类:
IOS方法总汇
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 分享 3 个 .NET 开源的文件压缩处理库,助力快速实现文件压缩解压功能!
· Ollama——大语言模型本地部署的极速利器
· DeepSeek如何颠覆传统软件测试?测试工程师会被淘汰吗?