0

I'm using SWRevealViewController. My frontViewController displays the various different content of the app and the rearViewController displays a table with links to those options. So if my frontViewController is currently display the Home page I want the rearViewController menu table to highlight that row, and so on for each of the other options. To do this the menu or rearViewController needs to know which view is being displayed by the frontViewController. I have tried setting a restorationIdentifier on each of the ViewControllers displayed by the frontViewController and then accessing them in the menuViewcontroller but each time they return nil.

So I was doing something like this in the menuViewControllers viewDidLoad method

self.revealViewController.frontViewController.restorationIdentifier

I also set the restorationIdentifiers on VC Views and tried this:

self.revealViewController.frontViewController.view.restorationIdentifier

but that also returned null

Linda Keating
  • 2,215
  • 7
  • 31
  • 63

1 Answers1

0

I think when you're in viewDidLoad, the reveal controller hasn't hooked up to the rear view or possibly even the front VC yet. So you're getting nil from self.revealViewController is my guess.

Try this in viewWillAppear instead.

Graham Perks
  • 23,007
  • 8
  • 61
  • 83
  • Yep I tried that as well. I should have stated in the question. Same result – Linda Keating Sep 15 '15 at 21:11
  • What is returning nil then? self.revealViewController? self.revealViewController.frontViewController? Or just the restorationId? – Graham Perks Sep 15 '15 at 23:54
  • The restorationId. I've implemented a work around based on the selected cell of the table, I can figure out what was the last option that the user pressed and therefore in (most) cases it is the content that is currently in the frontViewController. I also tried setting tags on the views presented by the frontviewController but these always evaluated to 0 even when I had set different values to them in the storyboard. – Linda Keating Sep 16 '15 at 08:02
  • I would double check the class of self.revealViewController.frontViewController, it might not be what you expect. For example, it might be your app's UINavigationController or tab controller. In that case you'll have to dig a bit deeper to reach the VC you want. – Graham Perks Sep 16 '15 at 16:12