Reputation: 13516
I have this code [tableView deselectRowAtIndexPath:indexPath animated:YES];
Why doesn't the table view deselect the row, What am i doing wrong.
EDIT:
-(void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
Upvotes: 0
Views: 542
Reputation: 523704
-(void)tableView:(UITableView*)tableView didDeselectRowAtIndexPath:(NSIndexPath*)path {
//------------------------------------------^^^^^^^^
// huh?
[tableView deselectRowAtIndexPath:path animated:YES];
}
The …didDeselect…
method is called only when the cell is already deselected. But you want to deselect that cell only after it's already deselected... sounds strange? Perhaps you mean …didSelect…
?
-(void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*)path {
//------------------------------------------^^^^^^
// yay.
[tableView deselectRowAtIndexPath:path animated:YES];
}
Upvotes: 4
Reputation: 6095
If your trying to stop your users from being able to select a row in your table view, this is the code you need:
- (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
return nil;
}
Upvotes: 0
Reputation: 96974
A couple ideas:
NSLog
to troubleshoot the value of indexPath
tableView
is wired up to the view controller in Interface BuilderUpvotes: 0