【问题标题】:Why Does presentModalViewController:animated: Turn The Background Black?为什么会出现 Modal ViewController:animated: Turn the Background Black?
【发布时间】:2011-11-07 13:42:13
【问题描述】:

我正在使用 presentModalViewController:animated:,虽然在功能上它可以正常工作,但它有一个我想要删除的伪影。当模态呈现的 viewController 出现时,它的父 viewController 完全隐藏,背景变黑。这不是我想要的。我的子 viewController 的视图是半透明的,我想显示它背后的父 viewControllers 视图。我想要的效果是一张描图纸在背景上滑动。

我假设 presentModalViewController:animated: 支持这个。不是这样吗?

谢谢,
道格

【问题讨论】:

    标签: ios uiviewcontroller presentmodalviewcontroller


    【解决方案1】:

    NavigationControllerView Controllers 的设计方式是一次只能显示一个视图控制器。当一个新的视图控制器被推送/呈现时,之前的视图控制器将被系统隐藏。因此,当您减少模态视图的 alpha 时,您可能会看到 窗口的 backgroundColor(您现在看到的 黑色)。

    如果您希望半透明视图滑入主视图,您可以将视图添加为主视图的subView,并使用UIView Animations 对其进行动画处理。

    【讨论】:

    • 叹息,我害怕那个。不幸的是,合成对于 UIKit 来说是如此的基础。谢谢。
    【解决方案2】:

    这可能会得到你想要的:

    presentingViewController.modalPresentationStyle = UIModalPresentationCurrentContext;
    

    【讨论】:

      【解决方案3】:

      presentingViewController.modalPresentationStyle = UIModalPresentationCurrentContext; 在ios7后无法使用,你可以在之后修复它

      presentingViewController.modalPresentationStyle = UIModalPresentationOverCurrentContext;
      presentingViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;

      然后两者: [appViews.rootViewController presentViewController:presentingViewController animated:YES completion:nil];

      【讨论】:

      • 值得注意的是,您可以通过界面生成器在模态呈现的 Segue 上进行设置。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-14
      • 2020-04-29
      • 2021-07-29
      • 2012-03-26
      相关资源
      最近更新 更多