我有一个 UIViewController
,它嵌入在 UINavigationController
中。在那个 View Controller 中,我有一个 UIButton
,它显示一个弹出 View ,它是另一个 UIViewController
(pVC)。它通过设置为 showModally
的 segue
来实现。在弹出窗口中,我只有一个 UIView
。
现在,我将我的 pVC 的背景颜色设置为清除,因此当点击按钮时,它会产生一种效果,就像只显示 pVC 内部的 View 一样。
问题是,当我将 pVC 的背景颜色设置为 clear
并点击按钮时,pVC 会按预期出现在我当前的 view controller
之上,但是之后一秒钟,背景变成黑色。这是它的样子:
在 View Hierarchy Debugger
中,我看到这是一个变成黑色的 UIWindow
层。我想知道,这可能是因为我以前的 view controller
嵌入在 UINavigationController
中?当我尝试对两个 UIViewControllers
执行相同操作时,它们都没有嵌入任何内容,但它工作正常。
如果您知道发生这种情况的确切原因和/或如何解决问题,我将不胜感激您的帮助。
最佳答案
尝试在当前上下文中以模态方式显示 pVC
,这样做:
The views beneath the presented content are not removed from the view hierarchy when the presentation finishes. So if the presented view controller does not fill the screen with opaque content, the underlying content shows through.
关于ios - 黑色背景屏幕,同时显示弹出 View ,使用单独的 UIViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48240286/