Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to set app orientation #579

Closed
prawnydagrate opened this issue Aug 14, 2020 · 1 comment
Closed

Unable to set app orientation #579

prawnydagrate opened this issue Aug 14, 2020 · 1 comment

Comments

@prawnydagrate
Copy link

prawnydagrate commented Aug 14, 2020

I'm creating a game with KivyMD and it has resizing issues. Resizing works well on Linux, Windows, and macOS but on a phone, there's problems. For Android, I used plyer.orientation.set_portrait(). I could also specify the app orientation in my buildozer.spec file. But for iOS, plyer.orientation doesn't work. Is there any way I could specify the app orientation in my Xcode project or be able to set the orientation with Plyer? BTW, plyer.orientation works on Manjaro Linux.

@prawnydagrate
Copy link
Author

I found

void export_orientation() {
    NSDictionary *info = [[NSBundle mainBundle] infoDictionary];
    NSArray *orientations = [info objectForKey:@"UISupportedInterfaceOrientations"];

    // Orientation restrictions
    // ========================
    // Comment or uncomment blocks 1-3 in order the limit orientation support

    // 1. Landscape only
    // NSString *result = [[NSString alloc] initWithString:@"KIVY_ORIENTATION=LandscapeLeft LandscapeRight"];

    // 2. Portrait only
    // NSString *result = [[NSString alloc] initWithString:@"KIVY_ORIENTATION=Portrait PortraitUpsideDown"];

    // 3. All orientations
    NSString *result = [[NSString alloc] initWithString:@"KIVY_ORIENTATION="];
    for (int i = 0; i < [orientations count]; i++) {
        NSString *item = [orientations objectAtIndex:i];
        item = [item substringFromIndex:22];
        if (i > 0)
            result = [result stringByAppendingString:@" "];
        result = [result stringByAppendingString:item];
    }
    // ========================

    putenv((char *)[result UTF8String]);
    NSLog(@"Available orientation: %@", result);
}

in my Sources/main.m file and was able to make my app all portrait.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant