使用模态视图控制器和UIVisualEffectView

11

我正在尝试解决这篇博客文章中描述的问题:http://justabeech.com/2014/10/22/using-uivisualeffectview-in-a-modal-view-controller/

我有一个包含故事板模式转场的UIViewController,其背景颜色为[UIColor clearColor],并带有一个UIVisualEffectViewUIView

当我展示视图控制器时,视觉效果会变得模糊,直到过渡完成,然后背景再次变灰(与该博客文章中显示的gif完全相同)。

enter image description here

我将 Modal Transition Style 设置为 FullScreen,但仍然存在同样的问题。我还缺少什么来使它正常工作?

编辑:我还收到以下错误:

Warning: Attempt to present <ClocksDetailViewController: 0x7ff89cb5bc70> on <ClocksViewController: 0x7ff89c8afe90> whose view is not in the window hierarchy!

谢谢


我认为这不是它。FullScreen演示文稿样式应该保持视图在下面。 - Max Woolf
你可以在模态转换后调试视图来轻松找出。如果下面的 VC 应该透过显示,那么它仍然会在视图层次结构中。 - Fogmeister
2
你是否真正使用过文章中提到的 UIModalPresentationOverFullScreen,还是用的 UIModalPresentationFullScreen?请注意它们之间的区别。 - Sulthan
是的,我错了。就是这样,谢谢你,Sulthan! - Max Woolf
只需查看此帖子。复制并粘贴代码> https://dev59.com/cGAf5IYBdhLWcg3wqUON#44400909 - Pedro Romão
显示剩余2条评论
2个回答

17
你可能使用了错误的UIModalPresentationFullScreen而不是正确的UIModalPresentationOverFullScreen。旧版的UIModalPresentationFullScreen会在动画结束后从视图层次结构中删除所有被呈现控制器下面的视图。

0

你需要设置UINavigationController的模态呈现样式,而不是UIViewController。

UINavigationController* navigationController = [[UIStoryboard storyboardWithName:@"myStoryboard" bundle:nil] instantiateViewControllerWithIdentifier:@"myViewController"];
navigationController.modalPresentationStyle = UIModalPresentationOverFullScreen;

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接