(Xcode6、iOS8、Swift、iPad)
(Xcode6, iOS8, Swift, iPad)
我正在尝试创建一个经典的类似 Web 的模式视图,其中对话框的外部是灰色的".为此,我将模态视图的 backgroundColor 的 alpha 值设置为 0.5,如下所示:
I am trying to create a classic Web-like modal view, where the outside of the dialog box is "grayed-out." To accomplish this, I've set the alpha value of the backgroundColor of the view for the modal to 0.5, like so:
self.view.backgroundColor = UIColor.blackColor().colorWithAlphaComponent(0.5)
唯一的问题是当模态变为全屏时,呈现视图被移除.(参考 导航控制器上的透明模态视图).
The only problem is that when the modal becomes full-screen, the presenting view is removed. (Ref Transparent Modal View on Navigation Controller).
(对这里的概念有点恼火.为什么要删除底层视图?根据定义,模态显示在其他内容之上.一旦底层视图被删除,它就不再是真正的模态了.它介于模态之间和一个推式过渡.哇哇哇......无论如何......)
(A bit irritated at the concept here. Why remove the underlying view? A modal is, by definition, to appear atop other content. Once the underlying view is removed, it's not really a modal anymore. it's somewhere between a modal and a push transition. Wa wa wa... Anyway..)
为了防止这种情况发生,我在父控制器的 viewDidLoad
方法和 Storyboard 中将 modalPresentationStyle
设置为 CurrentContext
...但没有运气.
To prevent this from happening, I've set the modalPresentationStyle
to CurrentContext
in the viewDidLoad
method of the parent controller, and in Storyboard... but no luck.
self.modalPresentationStyle = UIModalPresentationStyle.CurrentContext
self.navigationController.modalPresentationStyle = UIModalPresentationStyle.CurrentContext
当模态变为全屏时,如何防止正在显示的视图被移除?
How do I prevent the presenting view from being removed when the modal becomes full screen?
tyvm.. 更多信息如下.
tyvm.. more info below.
也在情节提要中,像这样(演示:当前上下文)
Also in Storyboard, like so (Presentation: Current Context)
感谢您的帮助...文档如下:
Thx for your help... documentation below:
首先,移除代码中所有显式的模态展示样式设置,然后执行以下操作:
First, remove all explicit setting of modal presentation style in code and do the following:
modalPresentation
样式设置为 Over Current context
modalPresentation
style to Over Current context
Provide Context
和 Define Context
中的复选框.他们似乎在不受限制地工作.Provide Context
and Define Context
.
They seem to be working even unchecked.这篇关于如何在 Swift 中的当前视图上呈现模态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!