0

When I layer SWRevealViewController over a normal UIViewController's view, to achieve a sliding left menu effect, it works as intended.

However, when this view controller is embeded on a UINavigationController, it overlays the navigation bar and hides the image and left and right BarButtonItems.

I'd appreciate some help finding a workaround.

This is how I'm adding this buttons:

UIBarButtonItem *revealButtonItem = [[UIBarButtonItem alloc] initWithImage: [UIImage imageNamed:@"icon-back"]
                                                                      style:UIBarButtonItemStylePlain
                                                                    target:self.revealViewController action:@selector(revealToggle:)];
UIBarButtonItem *saveExitButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"out"]
                                                                     style:UIBarButtonItemStylePlain
                                                                    target:self action:@selector(saveExit)];

self.navigationController.navigationItem.leftBarButtonItem = revealButtonItem;
self.navigationController.navigationItem.rightBarButtonItem = saveExitButtonItem;

Added this repository to show my point I'm using this component https://github.com/John-Lluch/SWRevealViewController:

https://github.com/AresDev/revealtest.git

Main.storyboard is working, just change in project settings the main interface to NonWorking.storyboard to see the error.

AresDev
  • 538
  • 4
  • 8

2 Answers2

0

I've found the solution, the navigation item that I have to add the buttom items is actually the RevealViewController navigation item.

UIBarButtonItem *revealButtonItem = [[UIBarButtonItem alloc] initWithImage: [UIImage imageNamed:@"icon-back"]
                                                                  style:UIBarButtonItemStylePlain
                                                                target:self.revealViewController action:@selector(revealToggle:)];

UIBarButtonItem *saveExitButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"out"]
                                                                 style:UIBarButtonItemStylePlain
                                                                target:self action:@selector(saveExit)];

self.revealViewController.navigationItem.leftBarButtonItem = revealButtonItem;
self.revealViewController.navigationItem.rightBarButtonItem = saveExitButtonItem;
AresDev
  • 538
  • 4
  • 8
-1

This what I understood from your question: You are trying to put together a navigation drawer view controller. If so then you could refer to: https://github.com/mutualmobile/MMDrawerController

If not then please elaborate your query.

Gajendra Mali
  • 316
  • 2
  • 6