iDevelopper / PBRevealViewController

A UIViewController subclass for revealing a left and/or right view controller above or below a main view controller.
MIT License
80 stars 16 forks source link

Help me finding the way to implement it correctly #21

Closed riyanpratamap closed 7 years ago

riyanpratamap commented 7 years ago

Hi, first of all this is great library! But I have one question regarding this implementation. So I created one project, and it has 3 menu item on its left menu controller. From each page on its menu, it has 3 button in bottom. See my picture

screen shot 2017-01-23 at 6 19 07 pm

On didSelectRowAtIndexPath's left menu table, I can "move" to 1,2, and 3 view controller by using

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MyStoryboard" bundle:nil];
UIViewController *controller = [[UINavigationController alloc] initWithRootViewController:[storyboard instantiateViewControllerWithIdentifier:@"MyStoryboardViewController"]];
[self.revealViewController pushMainViewController:controller animated:YES];

On 1, 2, and 3 View Controller, I initialize hamburger menu on navigation item with this

UIBarButtonItem *barButton = [[UIBarButtonItem alloc] init];
UIImage *imgBtn = [UIImage imageNamed:@"menu"];
[barButton setImage:imgBtn];

barButton.target = self.revealViewController;
barButton.action = @selector(revealLeftView);

self.revealViewController.toggleAnimationType = PBRevealToggleAnimationTypePushSideView;
self.navigationItem.leftBarButtonItem = barButton;

And each view controller has custom UIView that consist of 3 button. It is like bottom tab bar on Spotify for iOS. It will navigate to A, B, and C view controller that has slidemenu button also.

screen shot 2017-01-23 at 6 26 39 pm

Right now, I can navigate to A, B, and C by creating delegate on its custom view that require instance of destination UIViewController as parameter so I can present that view controller using

[self presentViewController:vc animated:YES completion:nil];

But as the result, A, B, and C view controller can't initialize its slidemenu using code like on 1, 2, and 3 view controller. It hamburger menu is created, but it can't show slidemenu as it should be.

So where I did wrong here? I think my fault is on how to present A, B, and C view controller that use presentViewController. Or another one? Any sugestion would be appreciated. Thank you so much!

iDevelopper commented 7 years ago

Thanks a lot!

Are the A, B and C controllers the same when calling from left menu or from the bottom bar? Is the bottom bar a UITabBarController?

iDevelopper commented 7 years ago

Instead of:

[self presentViewController:vc animated:YES completion:nil];

Use:

[self.revealViewController setMainViewController:vc animated:YES];

In this case the vc controller presented will keep a revealViewController property as it is presented with it.

riyanpratamap commented 7 years ago

Wow, thank you sooo much! It works like a charm! Again, thank you so much!

iDevelopper commented 7 years ago

Welcome!