开发者

How to unselect a UITableViewCell after you have done some action using didSelectRowAtIndexPath?

开发者_如何学运维Currently I do some work inside the didSelectRowAtIndexPath delegate and noticed that my row is still "selected" after I come back to the view controller later.

How can I unselect this row inside the delegate itself?

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  //do logic and ... it remains selected in the view?
}


[tableView deselectRowAtIndexPath:indexPath animated:YES];


Typically, you want to deselect the row when the view controller appears again:

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];

    [self.tableView deselectRowAtIndexPath:[self.tableView indexPathForSelectedRow] animated:YES];
}

That's what UITableViewController does implicitly, and animating the deselection process after the view controller appears again is a helpful hint to the user as to which cell they selected previously.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜