最新下载
热门教程
- 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方法中则完成取消表格行的选择,并且实现了动画效果。
相关文章
- picacg官网-最新入口2026 03-14
- PP视频是什么-PP视频如何关闭自动续费 03-14
- 126邮箱官方登录主站直达入口-126邮箱多端同步验证快捷入口 03-14
- 古文翻译神器推荐-文言文转换工具精选 03-14
- 18C.MIC天堂传送门极速直达-18C.MIC天堂官网一键入口 03-14
- mw777蛙漫漫画入口-mw777蛙漫网页版免费漫画畅读入口 03-14