I am new to making iOS apps. I have currently built a Split View based app. There is an array in the left had table and what ever is touched it loads the relating xib file in the detail view.
Now I want a home button to work. I want this to basically reload the DetailViewController to scratch. I have got it working like this so far:
- (IBAction)homeButtonPressed:(id)sender;
{
[[NSBundle mainBundle] loadNibNamed:@"DetailView" owner:self options:nil];//load xib
self.navigationItem.rightBarButtonItem = nil;//hide the home button
[self setTitle:@"Driveway Code"];//display the title
}
But the problem with this is that it still has the row selected in the left hand side. And I cannot seem to un select it.
If you could provide me with help either to reload the split view again or to just unselect the row. I would be happy. Thanks 🙂
UPDATE:
I have now go this:
- (IBAction)homeButtonPressed:(id)sender;
{
[[NSBundle mainBundle] loadNibNamed:@"DetailView" owner:self options:nil];
self.navigationItem.rightBarButtonItem = nil;
[self setTitle:@"Driveway Code"];
DetailViewController *dvc = [[DetailViewController alloc] init]; [dvc setTableView:tableView];
[tableView deselectRowAtIndexPath:detailItem animated:YES];
}
Use this method to select row programmatically:
and this one for deselect