8

I implement SWRevealViewController with UITabbarController via storyboard. I want to display SWRevealViewController in first UITabBarItem only, in other UITabBarItem i don't want to open SWRevealViewController, that done completely. But problem is position of UITabBar is not change like viewcontroller while SWRevealViewController is appear.

Please help me.

enter image description here

Storyboard structure enter image description here

Pramod Tapaniya
  • 1,228
  • 11
  • 30
  • You can use UIContainerViewController in your app. More info can be found on https://developer.apple.com/library/ios/featuredarticles/ViewControllerPGforiPhoneOS/ImplementingaContainerViewController.html and an example http://www.thinkandbuild.it/working-with-custom-container-view-controllers/ – Gagan_iOS Jan 18 '16 at 09:30
  • @Gagan_iOS i can't understand how to use. please elaborate. – Pramod Tapaniya Jan 18 '16 at 09:36
  • ok, You are using UITabBarController & Each tab would have a UIViewController. So you have to add UIContainerView on a particular tab's UIViewController. Here is an example for adding as you want. http://mobileoop.com/how-to-use-container-view-controller You have to just implement this coding on your tab's UIViewController. – Gagan_iOS Jan 18 '16 at 09:43
  • @Gagan_iOS yes is possible but i think it is very lengthy way. any solution with SWrevealviewcontroller. – Pramod Tapaniya Jan 18 '16 at 09:52
  • I implemented in this way and now It's upon you. try it if you want. – Gagan_iOS Jan 18 '16 at 09:55
  • @Gagan_iOS wait for SWrevealviewcontroller solution, not found then try your solution. – Pramod Tapaniya Jan 18 '16 at 09:56
  • SWRevealController needs one Front Controller & one rear view controller. Start your SWRevealController just before the First View Controller in your storyboard. That may help you. – AskIOS Jan 18 '16 at 10:07
  • @BharathVankireddy My initial view controller is tabbarviewcontroller not SWRevealController. – Pramod Tapaniya Jan 18 '16 at 10:09
  • In my opinion First View Controller means which you added as a controller to your first tab bar item. Make first tab bar item controller as SWRevealController. – AskIOS Jan 18 '16 at 10:10
  • @BharathVankireddy see my storyboard structure. – Pramod Tapaniya Jan 18 '16 at 10:27
  • what do you want exactly.. – iOS Developer Jan 18 '16 at 12:04
  • @iOSDeveloper i want change position of tabbar like viewcontoller while reveal is appear. – Pramod Tapaniya Jan 18 '16 at 12:12
  • check the answer @sudheer – iOS Developer Jan 18 '16 at 12:37

1 Answers1

2

I solve the problem by change position of UITabbar manually using SWRevealViewController delegate method. Put this code in MenuViewController.

MenuViewController.m

- (void) viewDidLoad {
    [super viewDidLoad];

    UITabBarController *tbc = (UITabBarController *)[[[[UIApplication sharedApplication]delegate]window]rootViewController];
    self.tabBar = tbc.tabBar;

    _tabBar.frame = CGRectMake(self.revealViewController.rearViewRevealWidth, _tabBar.frame.origin.y, _tabBar.frame.size.width, _tabBar.frame.size.height);
    self.revealViewController.delegate = self;
}

- (void) revealController:(SWRevealViewController *)revealController willMoveToPosition:(FrontViewPosition)position {
    if (position == FrontViewPositionRight) {
        _tabBar.frame = CGRectMake(self.revealViewController.rearViewRevealWidth, _tabBar.frame.origin.y, _tabBar.frame.size.width, _tabBar.frame.size.height);
    }
    else {
        _tabBar.frame = CGRectMake(0, _tabBar.frame.origin.y, _tabBar.frame.size.width, _tabBar.frame.size.height);
    }
}

- (void)revealController:(SWRevealViewController *)revealController panGestureMovedToLocation:(CGFloat)location progress:(CGFloat)progress overProgress:(CGFloat)overProgress {
    _tabBar.frame = CGRectMake(self.revealViewController.rearViewRevealWidth * progress, _tabBar.frame.origin.y, _tabBar.frame.size.width, _tabBar.frame.size.height);
}
Pramod Tapaniya
  • 1,228
  • 11
  • 30