For some reason after coming back to my parent UITableViewController
from child UIViewController
, the selected cell stays highlighted. I've tried the obvious solution below without any luck:
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self.tableView deselectRowAtIndexPath:[self.tableView indexPathForSelectedRow] animated:animated];
}
I narrowed the issue down to the following code:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *selectedString = [self tableView:tableView cellForRowAtIndexPath:indexPath].textLabel.text;
if([selectedString isEqualToString:@"Browser"])
{
[self performSegueWithIdentifier:@"showBrowser" sender:indexPath];
}
else if([selectedString isEqualToString:@"Settings"])
{
if([[User user] loggedIn])
{
[self performSegueWithIdentifier:@"showUserSettings" sender:indexPath];
}
else
{
[self performSegueWithIdentifier:@"showLogin" sender:indexPath];
}
}
else if([selectedString isEqualToString:@"Blank Page"])
{
[self performSegueWithIdentifier:@"showBrowser" sender:[NSURL URLWithString:@"about:blank"]];
}
}
Removing everything in - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
and putting just a single performSegueWithIdentifier
method WILL deselect the cell once coming back from the child, however what I have now does not deselect it.
I have also tried placing
[self.tableView deselectRowAtIndexPath:[self.tableView indexPathForSelectedRow] animated:YES];
in the didSelectRowAtIndexPath
method itself with no luck.
Any ideas?