I'm having trouble identifying the destinationViewController
using the SWRevealViewController
On certain ViewControllers I have used the prepareForSegue
method to identify the destination as follows:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([[segue identifier] isEqualToString:@"showHint"]) {
HintsViewController *hintsVC = [segue destinationViewController];
hintsVC.hintDelegate = self.controller;
hintsVC.hintUsed = self.controller.hintUsed;
hintsVC.firstLetterUsed = self.controller.firstLetterUsed;
hintsVC.answersUsed = self.controller.answersUsed;
}
These viewControllers are directly connected via Segues on the storyboard. And using this method I can identify the targetViewcontroller and set it as a delegate.
However I have a BarButtonItem in my FirstViewController that is connected to the MenuViewController as follows in the viewDidLoad
method
SWRevealViewController *revealViewController = self.revealViewController;
if(revealViewController){
[self.sideBarButton setTarget:self.revealViewController];
[self.sideBarButton setAction:@selector(rightRevealToggle:)];
revealViewController.rightViewRevealWidth = self.view.frame.size.width * 0.65;
}
This shows the MenuViewController and it is on the MenuViewController that I want to set as delegate.
So ideally I should be able to do something like:
MenuViewController* menuVC = revealViewController.destinationViewController;
menuVC.delegate = self;
However I can't identify the MenuViewControler using the viewDidLoad Method and I'm unsure of how to refactor the sidebarbutton to use a named storyboard segue.