当前位置: 动力学知识库 > 问答 > 编程问答 >

objective c - deselectRowAtIndexPath has no effect on a grouped UITableView

问题描述:

Grouped UITableViews don't appear to automatically animate the deselection of a row in the same way that plain UITableViews do, for example when a UITableViewController appears again after a detail view controller is pushed and subsequently popped. The iPhone Settings app does appear to implement this behaviour however.

I have tried to implement the behaviour in the viewWillAppear method of my grouped UITableViewController class but it simply has no effect:

- (void)viewWillAppear:(BOOL)animated {

[super viewWillAppear:animated];

//If returning from an edit then animate the deselection of the previously selected row

if ([self currentIndexPath] != nil)

{

[[self tableView] deselectRowAtIndexPath:[self currentIndexPath] animated:YES];

[self setCurrentIndexPath:nil];

}

...

The row and section properties of [self currentIndexPath] are always correct and valid according to my UITableView but the row deselection still does not animate. I've also tried deselecting the row using the following, again without success:

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

Please could someone help to shed some light on how this behaviour is implemented?

网友答案:

Is your indexpath correct?

I've absolutely no problems with this. Did you connect your TableView with self.tableview (if using an outlet connection)?

Best, Christian

分享给朋友:
您可能感兴趣的文章:
随机阅读: