Important: Please read the Qt Code of Conduct -

Set orientation on iOS at runtime

  • I have an app with the following settings in the plist file:


    They are the right settings, we need in our project.

    But I have one and only part as qml-view with a camera (for a barcode-scanner).
    These should be shown in all orientations, but at least landscape-orientation (left and right).

    I try to set this at runtime with a call from my c++ code:

    void MobileScreenOrientation::SetOrientation()
    //    NSNumber *value = [NSNumber numberWithInt:UIInterfaceOrientationLandscapeRight];
    //    [[UIDevice currentDevice] setValue:value forKey:@"orientation"];
        [[UIDevice currentDevice] setValue:@(UIInterfaceOrientationLandscapeLeft) forKey:@"orientation"];
        [UINavigationController attemptRotationToDeviceOrientation];

    but it it doesn't work. The orientation in my qml is still portrait.
    Can you help me, how can I set the landscape orientation on iOS at runtime, quasi manually?


Log in to reply