ios - 黑色背景屏幕,同时显示弹出 View ,使用单独的 UIViewController

标签 ios swift uiviewcontroller segue

我有一个 UIViewController,它嵌入在 UINavigationController 中。在那个 View Controller 中,我有一个 UIButton,它显示一个弹出 View ,它是另一个 UIViewController (pVC)。它通过设置为 showModallysegue 来实现。在弹出窗口中,我只有一个 UIView

现在,我将我的 pVC 的背景颜色设置为清除,因此当点击按钮时,它会产生一种效果,就像只显示 pVC 内部的 View 一样。

问题是,当我将 pVC 的背景颜色设置为 clear 并点击按钮时,pVC 会按预期出现在我当前的 view controller 之上,但是之后一秒钟,背景变成黑色。这是它的样子:

enter image description here

View Hierarchy Debugger 中,我看到这是一个变成黑色的 UIWindow 层。我想知道,这可能是因为我以前的 view controller 嵌入在 UINavigationController 中?当我尝试对两个 UIViewControllers 执行相同操作时,它们都没有嵌入任何内容,但它工作正常。

如果您知道发生这种情况的确切原因和/或如何解决问题,我将不胜感激您的帮助。

最佳答案

尝试在当前上下文中以模态方式显示 pVC,这样做:

enter image description here


关于overCurrentContext :

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/

相关文章:

ios - 在 Swift 4/Xcode 9 : AVF context unavailable for sharedAudioPresentationContext 中从 url 播放视频文件

iOS:具有多个 UIViewController 的类实例连接和架构

ios - 点击后退按钮时在 View 中显示消息

ipad - willRotateToInterfaceOrientation 未从呈现的 View Controller 中调用

ios - ASP.NET MVC Web 应用程序中的 Bing map 在移动 View 中无法正确显示

ios - 错误 : global. nativeTraceBeginSection 不是函数

ios - Xcode Swift sprite-kit SKS 文件动画在 SKS 文件中正常工作,但在模拟器或 iPhone 上不起作用

ios - 在字符串中查找最后一次出现的字符?

ios - 如何初始化一个新屏幕并转到它,同时将它添加到后台的 TableView

ios - 如何在 Swift 中实现全局化?