Qt World Summit: Submit your Presentation

Set iOS device orientation programmatically. How?

  • Hello all!
    Is there any way in QT set the device orientation programmatically or by force?

  • Hello,
    add the following entry in the .plist file

    (sorry for my english)

  • @Gerhard The key word in my message PROGRAMMATICALLY OR BY FORCE. It's mean from code, not from application settings.

  • Moderators

    @bogong you'll need to call objective c code, but it should be possible

    from here:

    UIInterfaceOrientation currentOrientation = [UIApplication sharedApplication].statusBarOrientation;
    NSNumber *value = [NSNumber numberWithInt:UIInterfaceOrientationPortrait];
    [[UIDevice currentDevice] setValue:value forKey:@"orientation"];    
    [UIViewController attemptRotationToDeviceOrientation];

  • @J-Hilk I know it. I've tried it. The orientation after this code detecting like you set. But QML interface not redrawing. It's working perfectly when I am using it in native Objective-C/Swift but QML interface not redrawing even appeared signal about changed orientation. Only after phisical changing orientation it's wrking. I've already spent 2 weeks for finding cause of it.

  • @J-Hilk but never the less - thx for reply. If, not if, when I get success with it - will publish example. Going to get next iteration of this issue tomorrow.

Log in to reply