Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

iOS Native Popup Orientation

Discussion in 'iOS and tvOS' started by keystagefun, Mar 4, 2021.

  1. keystagefun

    keystagefun

    Joined:
    Feb 19, 2020
    Posts:
    33
    Hi,

    I've looked but can't find the answer anywhere... thanks in advance for any help anyone can offer on this.

    During my in-app subscription process, the native iOS "popup" appears when you tap to make payment, asking you to enter your App Store credentials. All works well, except my app is running in landscape, but the popup appears in portrait mode, so essentially slides in from the side of the screen with the text and input field displayed in portrait, at 90 degrees to the way the user is holding the screen.

    Does anyone know if there is any way of forcing iOS in-app alerts / notifications to always run in landscape mode.

    I have set the orientation to "Landscape Left" in my build settings in Unity and this is mirrored in Xcode in the build.settings file.

    Any ideas would be hugely appreciated.

    Thanks,

    Ian
     
  2. aihodge

    aihodge

    Joined:
    Nov 23, 2014
    Posts:
    164
    Not sure if this will do the trick in your specific case, but I've had success using the following workaround to force landscape orientation for certain native iOS UI elements that prefer portrait orientations. The trick is to override the supportedInterfaceOrientationsForWindow() method in the UnityAppController.mm file of the generated Xcode project with something like this:

    Code (CSharp):
    1. -(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
    2. {
    3.     if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
    4.         return UIInterfaceOrientationMaskAll;
    5.     else
    6.         return UIInterfaceOrientationMaskAllButUpsideDown;
    7. }
    Keep in mind this would apply globally to the app, so any third party plugins which present native UIs would be impacted by this change.

    Hope this helps!
     
  3. keystagefun

    keystagefun

    Joined:
    Feb 19, 2020
    Posts:
    33
    Thanks for the reply - much appreciated. Interesting... I'll give it a go.