iphone - 隐藏UITabBar而不使用presentModalViewController或pushViewController

问题描述 投票:0回答:3

嘿伙计们,就像问题所说,我试图在不使用presentModalViewController或pushViewController的情况下在UIDatePicker中滑动,然后隐藏应用程序的主UITabBar。现在,我将UIDatePicker子视图与导航栏上的几个按钮添加到临时UIViewController,并使用该临时控制器作为根初始化UINavigationController。我将此导航控制器作为子视图添加到self.navigationController.tabBarController以尝试覆盖UITabBar,但是当我将UITabBar设置为隐藏时,我看到的只有白色,没有UIDatePicker可见。有什么建议?

注意:我的理由是我无法想出一种方法来使用带有小于屏幕的视图的presentModalViewController。

iphone objective-c uinavigationcontroller uitabbar
3个回答
1
投票

如果您需要这样的设计:

http://clip2net.com/clip/m13204/1248480575-clip-22kb.jpg

您可以阅读示例here(UIActionSheet + UIDatePicker)。另请参阅UICatalog Apple示例以获取更多信息。


5
投票

回答here,Hide UiTabBar

更新:来自链接的代码

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;
}

更新:修改代码在iPad(在模拟器中测试)和iPhone(未测试,但希望它将工作)上工作qazxsw poi


0
投票

您可以查看Apple的DateCell示例。当您调用becomeFirstResponder时,UIDatePicker会像UITextField的键盘一样从底部滑动。

© www.soinside.com 2019 - 2024. All rights reserved.