简体   繁体   中英

Using Modal View Controllers and UIVisualEffectView

I'm trying to solve the problem described in this blog post: http://justabeech.com/2014/10/22/using-uivisualeffectview-in-a-modal-view-controller/

I have a UIViewController with a storyboard modal segue to another UIViewController of which the UIView has a background colour of [UIColor clearColor] and a UIVisualEffectView .

When I present the view controller, the visual effect is blurred until the transition is completed and then the background turns grey again (exactly as displayed in the gif on that blog post).

在此输入图像描述

I set the Modal Transition Style to FullScreen as specified, but still the same problem remains. What else could I be missing to make this work?

EDIT: Also, I get the following error:

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

Thanks

You have probably used UIModalPresentationFullScreen instead of the correct UIModalPresentationOverFullScreen .

With the old UIModalPresentationFullScreen all the views under the presented controller are removed from the view hierarchy once the animation ends.

You need to set the modal presentation style of the UINavigationController, instead of the the UIViewController.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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