2

I have a home page and when a certain button is pressed, it takes you to a split view with a table on the left (master) side and a view showing details on the right (detail) side. The app is working fine on the simulator, but when I run on my iPad mini I get an error.

When the user clicks on a table cell in the left (master) view, I call:

DetailViewController *detail = [self.storyboard instantiateViewControllerWithIdentifier:@"detailViewController"];
detail.jobInfo = [_fetchedResultsController objectAtIndexPath:indexPath];
[self.splitViewController showDetailViewController:detail sender:self];

That updates the detail view in the simulator, but crashes and gives me the following error on a device:

'-[UISplitViewController showDetailViewController:sender:]: unrecognized selector sent to instance' 

Any suggestions on how to fix this?

MSU_Bulldog
  • 3,501
  • 5
  • 37
  • 73
  • Is the device on iOS 8? – pbasdf Oct 09 '14 at 13:41
  • no it has 7.1.2, does that method only work on iOS 8? – MSU_Bulldog Oct 09 '14 at 13:48
  • Could you suggest a way to get this same result for earlier versions of iOs? – MSU_Bulldog Oct 09 '14 at 13:53
  • Update the viewControllers property: viewControllers[0] is the master, [1] is the detail. But if you have a navigation controller on the detail side, you might prefer to push onto that instead. – pbasdf Oct 09 '14 at 13:54
  • The entire SplitView is in a navigation controller. I tried updating the viewControllers property and received the same error: unrecognized selector – MSU_Bulldog Oct 09 '14 at 13:59
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/62759/discussion-between-pbasdf-and-msu-bulldog). – pbasdf Oct 09 '14 at 14:06

1 Answers1

7

To update the viewControllers property directly, do this:

NSArray *vcs = @[self.splitViewController.viewControllers[0],detail];
self.splitViewController.viewControllers = vcs;
pbasdf
  • 21,386
  • 4
  • 43
  • 75
  • Perfect Answer! All was workin fine on simulator but on device crash! this answer fixed it! – Nitya Jan 06 '15 at 16:34