Workaround for custom UIViewController animations in landscape?

后端 未结 5 906
逝去的感伤
逝去的感伤 2021-01-31 05:34

I have a custom animated UIViewController transition, and it seems that there is a bug in iOS that screws up the layout in landscape orientation. In the main animation method, i

5条回答
  •  伪装坚强ぢ
    2021-01-31 05:48

    Ok, the fix is surprisingly simple:

    Set the toViewController frame to the container before adding the view to the container.

    toViewController.view.frame = containerView.frame;
    [containerView addSubview:toViewController.view];
    

    Update: There is still a limitation in that you don't know the orientation of the frame. It is portrait initially, but stretched into landscape when it is displayed on screen. If you wanted to slide in the view from the right, in landscape it might slide in from the "top" (or the bottom if viewing the other landscape!)

提交回复
热议问题