当前位置: 移动技术网 > IT编程>移动开发>IOS > IOS 开发之实现取消tableView返回时cell选中的问题

IOS 开发之实现取消tableView返回时cell选中的问题

2019年07月24日  | 移动技术网IT编程  | 我要评论

官场之高手过招,庚澈h文,fmg9电箱

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方法中则完成取消表格行的选择,并且实现了动画效果。

如有疑问请留言或者到本站社区交流讨论,感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网