最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
IOS 开发之实现取消tableView返回时cell选中的问题
时间:2022-06-26 05:59:20 编辑:袖梨 来源:一聚教程网
在对表格UITableView操作时,有时当用户选中表格行后,需要自动取消选择。实现这种效果,其原理是选中表格行时,会调用 didSelectRowAtIndexPath方法,只要在这个方法中,调用performSelector执行取消选中表格行的方法。
示例代码如下:
- (void) unselectCurrentRow { // Animate the deselection [self.tableView deselectRowAtIndexPath:[self.tableView indexPathForSelectedRow] animated:YES]; } - (void)tableView:(UITableView *)tableViewdidSelectRowAtIndexPath:(NSIndexPath *)newIndexPath { // Any other table management you need ... // After one second, unselect the current row [self performSelector:@selector(unselectCurrentRow)withObject:nil afterDelay:1.0]; }
在performSelector中还可以设定延迟时间。unselectCurrentRow方法中则完成取消表格行的选择,并且实现了动画效果。
相关文章
- 银与绯吉尔兰技能怎么样 吉尔兰战斗特性解析 07-14
- 异环异象管理局局长是谁 艾尔菲德角色详细介绍 07-14
- 欧意易ok官网下载版 欧意易app下载 07-14
- 迷你世界马车怎么做 马车制作方法介绍 07-14
- 碳碳岛许愿池有什么作用 许愿池建造方法介绍 07-14
- 最终幻想14水晶世界怎么招募雇员 招募雇员方法介绍 07-14