iOS 13 UIViewController 未声明将其 modalPresentationStyle 恢复为全屏

jim*_*buk 7 uiviewcontroller ios state-restoration ios13

我在我的应用程序中的大多数模态中都采用了新的 iOS 13 模态呈现样式,但是一个导航控制器并不能很好地适应新样式,因此我将其设置为

UIModalPresentationFullScreen

在展示它时效果很好。

我刚刚注意到一个错误,当我的应用程序在 ViewController 上进行状态保存和恢复时,它会在以 UIModalPresentationPageSheet 的 modalPresentationStyle 恢复后以模态呈现。

作为 ViewController 的内置属性,它们的状态恢复是 Apple 的责任,我猜他们只是错过了正确处理它。

谢天谢地,我已经能够通过将以下内容添加到我现有的状态恢复处理中来解决这个问题

- (void)decodeRestorableStateWithCoder:(NSCoder *)aDecoder
{
  ...
  self.navigationController.modalPresentationStyle = UIModalPresentationFullScreen; 
}
Run Code Online (Sandbox Code Playgroud)

其他人遇到过这个问题或有其他解决方案吗?

干杯