0

Hey guys, like the question states, I am trying to slide in a UIDatePicker without using presentModalViewController or pushViewController and subsequently hide the main UITabBar of the application. Right now, I am adding the UIDatePicker subview with a couple buttons on a Navigation Bar to a temporary UIViewController, and initializing a UINavigationController with that temporary controller as the root. I am adding this Navigation Controller as a subview to self.navigationController.tabBarController in an attempt to overlay the UITabBar, but when I set the UITabBar to hidden, all I see is white beneath it, with no UIDatePicker visible. Any suggestions?

Note: My reasoning for this is that I can't figure out a way to use presentModalViewController with a view smaller than the screen.

jmeado3
  • 239
  • 2
  • 4
  • 12

2 Answers2

5

Answer here, Hide UiTabBar

UPDATE: code from link

BOOL hiddenTabBar;
UITabBarController *tabBarController;

- (void) hideTabBar {

     [UIView beginAnimations:nil context:NULL];
     [UIView setAnimationDuration:0.4];
     for(UIView *view in tabBarController.view.subviews)
     {
          CGRect _rect = view.frame;
          if([view isKindOfClass:[UITabBar class]])
          {
               if (hiddenTabBar) {
                    _rect.origin.y = 431;
                    [view setFrame:_rect];
               } else {
                    _rect.origin.y = 480;
                    [view setFrame:_rect];
               }
          } else {
               if (hiddenTabBar) {
                    _rect.size.height = 431;
                    [view setFrame:_rect];
               } else {
                    _rect.size.height = 480;
                    [view setFrame:_rect];
               }
          }
     }    
     [UIView commitAnimations];

     hiddenTabBar = !hiddenTabBar;
}

UPDATE: Modified the code to work on both iPad (tested in simulator) & iPhone (not tested, but hopefully it will work) https://stackoverflow.com/a/8584684/336422

Community
  • 1
  • 1
Volodymyr B.
  • 3,369
  • 2
  • 30
  • 48
0

You could have a look to the DateCell example from Apple. UIDatePicker slide from bottom like UITextField's keyboard when you call becomeFirstResponder.

Antoine F.
  • 393
  • 6
  • 16