11

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).

enter image description here

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

Max Woolf
  • 3,988
  • 1
  • 26
  • 39
  • You need to take a snapshot of the "underneath" view and apply it as the background of the modal view. – Fogmeister Dec 11 '14 at 09:51
  • I don't think this is it. The FullScreen presentation style should keep the views underneath. – Max Woolf Dec 11 '14 at 09:54
  • You could easily find out by bugging the view after your modal transition. If the underneath VC should show through then it will still be in the view hierarchy. – Fogmeister Dec 11 '14 at 10:06
  • Just done an experiment project with a VC with a red background and a full screen transition to a VC with a clear background... I was right. – Fogmeister Dec 11 '14 at 10:07
  • 2
    Have you actually used the `UIModalPresentationOverFullScreen` mentioned in the article or have you used `UIModalPresentationFullScreen`? Note the difference. – Sulthan Dec 11 '14 at 10:10
  • Yeah, my bad. That's exactly it Sulthan, thanks! – Max Woolf Dec 11 '14 at 10:11
  • Just see this post. copy and paste the code > https://stackoverflow.com/a/44400909/2283308 – Pedro Romão Jun 06 '17 at 22:55

2 Answers2

17

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.

Sulthan
  • 128,090
  • 22
  • 218
  • 270
0

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;
Regexident
  • 29,441
  • 10
  • 93
  • 100
Robert Wagstaff
  • 2,664
  • 1
  • 27
  • 40