【问题标题】:UIPresentationController not calling containerViewWillLayoutSubviews until after displayUIPresentationController 直到显示后才调用 containerViewWillLayoutSubviews
【发布时间】:2023-03-13 22:24:01
【问题描述】:

我有一个UIPresentationController 在主视图上显示一个侧边菜单,固定宽度为 300。然后用户可以从侧边菜单打开全屏模式视图。当模态视图被解除时,菜单视图在解除动画期间填充屏幕(这是错误的)。在动画结束时,containerViewWillLayoutSubviews 被调用,菜单将其宽度更正为 300。

我确实实现了frameOfPresentedViewInContainerView。我也在实现 shouldPresentInFullscreen 在菜单视图上返回 NO(尽管这似乎不会影响我真正确定的任何事情)。

为什么在dismssal动画之前不调用containerViewWillLayoutSubviews?当菜单视图被覆盖和显示时,我应该如何保持它的宽度?

【问题讨论】:

标签: ios uipresentationcontroller


【解决方案1】:

感谢 riadhluke 将我引导至 UIPresentationController changes size when another view controller is displayed on top of it

我的解决方案在我的菜单中prepareForSegue

UIViewController *destination = [segue destinationViewController];
if (destination.modalPresentationStyle == UIModalPresentationFullScreen) {
    destination.modalPresentationStyle = UIModalPresentationOverFullScreen;
}

这会强制全屏模式呈现在全屏状态,这会导致菜单不会丢失,因此不会重新布置关闭后的动画。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-03
    • 1970-01-01
    • 1970-01-01
    • 2018-02-07
    • 1970-01-01
    相关资源
    最近更新 更多