Search code examples
objective-cios11iphone-x

presentViewController in full screen mode on iPhone X


As you know there are no problems when we present a view controller with the full-screen option before:

modalPresentationStyle = UIModalPresentationFullScreen;

However, on iPhone X, it will be overlapped by the top-notch and bottom bar. Do you have any solution for that without customizing presenting controller's (from a static library) subviews?

Thank you!


Solution

  • There is a trick to prevent the issues with iPhone X without modifying the presenting controller (Controller A) from a static library like this:

    1. Create a new controller (Controller B) add a subview which applies the auto layout to the safeAreaLayoutGuide.

    2. Init Controller A of the static library inside Controller B, the add Controller A's view to Controller B's subview.

    3. Present Controller B instead of direct present Controller A