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

IOS orientation doesn't set #355

Open
ghost opened this issue May 18, 2016 · 3 comments
Open

IOS orientation doesn't set #355

ghost opened this issue May 18, 2016 · 3 comments

Comments

@ghost
Copy link

ghost commented May 18, 2016

Whether I specify portrait or landscape in the buildozer.spec, when I launch the app via buildozer ios debug deploy run, it uses both portrait and landscape. Any workaround? I want to specify portrait only or landscape only at times.

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@hackalog
Copy link
Contributor

As of Jan 2019, this still requires manual editing of main.m (this is mentioned in a comment in that file, but I don't think anyone is expecting to have to edit it manually)

e.g. Here I've forced it to Landscape-only

    // 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];
    //}
    // ========================

This is a pain to do all the time, so in our build scripts, we use a chunk of code like this to automate it:

    sed -i .ORIG 's/void export_orientation() {/void OLD_export_orientation() {/' $(IOS_BUILD_DIR)/$(IOS)-ios/main.m
    cat $(IOS_FILES_DIR)/export_orientation.m >> $(IOS_BUILD_DIR)/$(IOS)-ios/main.m

It's a brutal hack, but we basically just rename the original function, and append a copy of the function with the orientation set correctly.
Here's our export_orientation.m:

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

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

The right answer is either fix the code to check the environment, or add a conditional block to the cookiecutter, using some kind of jinja mojo.

@hackalog
Copy link
Contributor

I should also mention, this is likely also a kivy-ios issue, since the cookiecutter changes would have to happen there. I've opened an issue there and linked to this one

@Julian-O
Copy link
Contributor

On hold pending Kivy-ios support.

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

No branches or pull requests

2 participants