现在的位置: 首页 > 综合 > 正文

自动取消选中行

2013年10月11日 ⁄ 综合 ⁄ 共 452字 ⁄ 字号 评论关闭
在对表格UITableView操作时,有时当用户选中表格行后,需要自动取消选择。实现这种效果,其原理是选中表格行时,会调用 didSelectRowAtIndexPath方法,只要在这个方法中,调用performSelector执行取消选中表格行的方法。示例代码如下:

01 -
(
void)
unselectCurrentRow
02 {
03   //
Animate the deselection
04   [self.tableView
deselectRowAtIndexPath:
05       [self.tableView
indexPathForSelectedRow] animated:YES];
06 }
07   
08 -
(
void)tableView:(UITableView
*)tableView
09       didSelectRowAtIndexPath:(NSIndexPath
*)newIndexPath
10 {
11   //
Any other table management you need
12   ...
13   
14

抱歉!评论已关闭.