【问题标题】:Present UIViewController above TabBar在 TabBar 上方呈现 UIViewController
【发布时间】:2018-05-06 16:19:00
【问题描述】:

我正在使用 TabBarController,我想从其中一个选项卡中呈现另一个 UIViewController,同时保持 TabBar 显示。

如果我只是展示或推动视图控制器,它会在 TabBar 上方全屏显示。

解决这个问题的正确方法是什么?

【问题讨论】:

    标签: objective-c uitabbarcontroller tabbar presentviewcontroller


    【解决方案1】:

    假设ViewControllerAUIViewControllerTabBarController。而你要呈现的UIViewControllerViewControllerB

    推送ViewControllerB,同时保持 TabBar 显示。只需在ViewControllerA 中调用即可

    ViewControllerB *vc = // Initialize ViewControllerB here
    [self.navigationController pushViewController:vc animated:YES];
    

    介绍ViewControllerB

    ViewControllerB *vc = Initialize ViewControllerB here
    vc.modalPresentationStyle = UIModalPresentationOverCurrentContext;
    [self presentViewController:vc animated:YES completion:nil];
    

    在演示时,请确保将 UIModalPresentationOverCurrentContext 设置为 ViewControllerBmodalPresentationStyle 属性。如果没有,它将在TabBar 上显示全屏

    为了便于理解,我创建了a demo repo,你可以看看。

    【讨论】:

      猜你喜欢
      • 2021-09-11
      • 1970-01-01
      • 2016-10-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-05-29
      • 1970-01-01
      相关资源
      最近更新 更多