Reputation: 269
I'm using SWRevealViewController after following AppCoda's tutorial. I was able to get it working in the tutorial with no issues, but not able to adapt it to my own app. The reason is that in my app I don't use the SWRevealVC from the initial screen. The menu button to trigger the SWRevealVC doesn't appear until after a modal segue from the main screen. So from the main scene there is a modal segue to a new scene (RecipeDetailVC) which contains the menu button in the upper left to trigger the SWRevealVC. RecipeDetailsVC has its custom segue's identifier set as the front viewcontroller (sw_front). Nothing happens when I tap the menu button, no error or crash, but it just doesn't do anything. I'm sure the reason is that the RevealVC is dangling out there as you can see in the storyboard. Also, I made sure to set its class to the SWRevealVC class. Also, in the RecipeDetailsVC, which is the front VC, the (revealViewController) code in viewDidLoad never evaluates which is why nothing is happening when tapping the menu button. I'm sure this is related the dangling revealVC, but not sure how to correct it. Can anyone tell me how to correct this for this scenario? Thanks
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
NSLog(@"viewDidLoad...");
SWRevealViewController *revealViewController = self.revealViewController;
if (revealViewController)
{
NSLog(@"DEBUG: We have a revealVC!");
[self.sidebarButton setTarget:self.revealViewController];
[self.sidebarButton setAction:@selector(revealToggle:)];
[self.view addGestureRecognizer:self.revealViewController.panGestureRecognizer];
}
}
Upvotes: 1
Views: 643
Reputation: 877
SWRevealViewController should be the root view controller of the front and rear view controller. Try performing modal segue to the SWRevealViewController and not to the RecipeDetailVC navigation controller.
Upvotes: 1