简体   繁体   English

具有自定义过渡的UIViewController; 模态呈现后丢失

[英]UIViewController with Custom Transition; Lost After Modal Presentation

Scenario: one UIViewController uses a custom transition to present another VC. 场景:一个UIViewController使用自定义过渡呈现另一个VC。 This VC does not take up the entire screen; 此VC不会占据整个屏幕; it's appearing as a layer on top of the first. 它显示为第一个之上的一层。 Everything here is working great. 这里的一切都很好。

Now the presented VC wants to show a UIImagePickerController — to take a photo. 现在,所呈现的VC要显示UIImagePickerController —拍照。 But once that controller is dismissed, the second VC is displayed as a full-screen view: the effects of the original transition have been lost. 但是,一旦关闭该控制器,第二个VC就会以全屏视图显示:原始转换的效果已丢失。

I've borrowed someone else's demo code for UIViewController transitions to quickly demonstrate this effect. 我已经为UIViewController过渡借用了其他人的演示代码,以快速演示这种效果。 Once you add the partial-screen second VC and bring up the camera view, dismissing it leaves you with a full-screen second view. 添加部分屏幕的第二个VC并调出摄像机视图后,将其关闭会留下全屏的第二个视图。

I've been unable to find other folks having this issue, but its repeatability suggests a framework bug. 我一直找不到其他人遇到此问题,但其可重复性表明存在框架错误。

https://github.com/aaronvegh/CustomViewControllerTransition https://github.com/aaronvegh/CustomViewControllerTransition

Found the solution: you have to set a modalPresentationStyle property on the camera VC before showing it. 找到了解决方案:您必须在显示相机VC之前设置modalPresentationStyle属性。 In my instance I set it to UIModalPresentationCustom, and that resolved the issue: when the camera is dismissed, the underlying custom transition bounds are retained. 在我的实例中,我将其设置为UIModalPresentationCustom,从而解决了该问题:关闭摄像机后,将保留基础的自定义过渡范围。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM