这篇文章主要介绍了IOS 开发之实现取消tableView返回时cell选中的问题的相关资料,希望通过本文能实现大家想要的功能,需要的朋友可以参考下
IOS 开发之实现取消tableView返回时cell选中的问题
在对表格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方法中则完成取消表格行的选择,并且实现了动画效果。
如有疑问请留言或者到本站社区交流讨论,感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
织梦狗教程
本文标题为:IOS 开发之实现取消tableView返回时cell选中的问题
基础教程推荐
猜你喜欢
- android studio按钮监听的5种方法实例详解 2023-01-12
- Flutter手势密码的实现示例(附demo) 2023-04-11
- IOS 播放系统提示音使用总结(AudioToolbox) 2023-03-01
- Android中的webview监听每次URL变化实例 2023-01-23
- Android开发使用RecyclerView添加点击事件实例详解 2023-06-15
- IOS应用内跳转系统设置相关界面的方法 2022-11-20
- 解决Android Studio突然不显示logcat日志的问题 2023-02-04
- Flutter绘图组件之CustomPaint使用详解 2023-05-12
- Android多返回栈技术 2023-04-15
- iOS开发教程之XLForm的基本使用方法 2023-05-01
