【问题标题】:iOS 7 - hiding tabBar and showing toolBar insteadiOS 7 - 隐藏 tabBar 并显示 toolBar
【发布时间】:2014-04-24 23:03:44
【问题描述】:

我在隐藏 UITabBar 时遇到问题。我有一个自定义 tabBar,我使用它隐藏:

    self.frame = CGRectOffset(tabBarRect, 0, CGRectGetHeight(tabBarRect));

我想显示工具栏而不是 tabBar。一切看起来都很好,但我注意到以前被 tabBar 占用的区域没有响应,尽管我偏移了 tabBar 框架。

所以,我只是把toolBar作为tabBar的一个子视图:

    toolBar.frame = CGRectMake(0, CGRectGetHeight(tbv.frame) - toolBar.intrinsicContentSize.height, CGRectGetWidth(self.view.frame), toolBar.intrinsicContentSize.height); 
    [tbv addSubview:toolBar];

不幸的是,我的 tabBar 比 toolBar 大,所以我不能使用这个解决方案。 我知道我可以将 toolBar 添加到 appDelegate 的 keyWindow 和 tabBar 的顶部,但我想将它放在我的 viewController 中。

有什么方法可以禁用 tabBar 并在当前 viewController 中使用 toolBar 或任何其他带有手势的控件,它是基于导航的应用程序的一部分,带有 tabBar?

谢谢你

【问题讨论】:

    标签: ios objective-c uitabbar uitoolbar


    【解决方案1】:

    你可以试试self.hidesBottomBarWhenPushed =YES;

    像这样:

    self.hidesBottomBarWhenPushed =YES;//hide controller's tabbar
    
    UIViewController *controller =[self.storyboard instantiateViewControllerWithIdentifier:@"MyRequirementParticipateInViewController"];
    
    [self.navigationController pushViewController:controller animated:YES];
    
    self.hidesBottomBarWhenPushed =NO;//when pushed back tabbar would show again. 
    

    【讨论】:

    • 感谢 Jack,但我需要使用可见的 tabBar 推送相同的 viewController,然后,如果用户点击按钮,toolBar 应该替换 tabBar。我宁愿不实例化同一个 viewController
    猜你喜欢
    • 1970-01-01
    • 2013-12-28
    • 1970-01-01
    • 2013-10-14
    • 2018-05-24
    • 1970-01-01
    • 2021-10-18
    • 1970-01-01
    • 2011-08-17
    相关资源
    最近更新 更多