jondanao / TheSidebarController

A container view controller that implements different popular sidebar view controllers like Facebook, Airbnb, Flipboard, etc.
Other
360 stars 52 forks source link

sidebarController become unresponsive if the contentViewController is tabBarController #9

Closed bhavinchitroda closed 10 years ago

bhavinchitroda commented 10 years ago

I have a tab bar controller in storyboard that contains a bar button to open a side panel from left side. I used the below code to integrate thesidebarcontroller in my application...

LeftViewController *leftViewController = [[LeftViewController alloc] init];
leftViewController.view.backgroundColor = [UIColor colorWithRed:125.0 green:125.0 blue:125.0 alpha:0.5];
UITabBarController *contentViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"ViewController"];
TheSidebarController *sidebarController = [[TheSidebarController alloc] initWithContentViewController:contentViewController leftSidebarViewController:leftViewController];

I wrote the code for left bar button (to open sidepanel) in tabcontroller's first selected view controller, and confirmed with break points that it's being called on button press.

- (void)leftButtonClicked
{
   if(self.sidebarController.sidebarIsPresenting)
   {
        [self.sidebarController dismissSidebarViewController];
   }
   else
   {
       [self.sidebarController presentLeftSidebarViewControllerWithStyle:SidebarTransitionStyleAirbnb];
   }
}

But, side panel is not responding or opening !!!..

jondanao commented 10 years ago

Is the left button inside UINavigationController that is inside the UITabBarController? If so, then I know how to fix it.

bhavinchitroda commented 10 years ago

I tried to use self.tabBarController.sidebarController instead of self.sidebarController and it's working. Is that what you want me to try?

jondanao commented 10 years ago

I'm guessing it's the hierarchy of the category of the UIViewController here: https://github.com/jondanao/TheSidebarController/blob/master/TheSidebarController/TheSidebarController.m#L394

It can only reference the sidebarController until 3 levels deep (TheSidebarControlller > ContentContainerViewController > UINavigationController > UIViewController). Yours is 4 levels (TheSidebarControlller > ContentContainerViewController > UITabBarController > UINavigationController > UIViewController).

But your solution works because you're referencing the sidebarController from a 2-level depth which is supported. Thanks!

parthpatel1105 commented 9 years ago

If i want to present view controller in centerview controller than what should i do?

Please inform me on my mail id:- parthpatel1105@gmail.com