iOS 13 UIViewController doesn't state restore its modalPresentationStyle to fullscreen
Asked Answered
T

0

7

I've adopted the new iOS 13 modal presentation style across most of the modals in my app, however one navigation controller doesn't really fit the new style well so I set it to

UIModalPresentationFullScreen

when presenting it which works fine.

I just noticed a bug that when my app undergoes state preservation and restoration whilst on a ViewController being presented modally its loaded back in after restoration with a modalPresentationStyle of UIModalPresentationPageSheet.

As built in properties of a ViewController their state restoration is Apple's responsibility and I guess they just missed out handling it properly.

Thankfully I've been able to fix the issue by adding the following to my existing state restoration handling

- (void)decodeRestorableStateWithCoder:(NSCoder *)aDecoder
{
  ...
  self.navigationController.modalPresentationStyle = UIModalPresentationFullScreen; 
}

Anyone else encountered this or got an alternative solution?

Cheers

Turin answered 24/1, 2020 at 20:40 Comment(2)
Also experiencing this problem and your fix works. Have yet to find something more elegant... Seem to be getting a new warning: Unbalanced calls to begin/end appearance transitions for <UINavigationController: ...>. Thinking this is causing itChisolm
@Chisolm - nice spot. Here’s hoping they fix it eventually. I’d log a bug with Apple about it but it takes more time than I’ve got to do and I’m sure they’re aware of it. Glad this fix worked for you.Turin

© 2022 - 2024 — McMap. All rights reserved.