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

Orientation issues in iOS 8 #4154

Open
danoli3 opened this issue Jul 26, 2015 · 1 comment
Open

Orientation issues in iOS 8 #4154

danoli3 opened this issue Jul 26, 2015 · 1 comment

Comments

@danoli3
Copy link
Member

danoli3 commented Jul 26, 2015

As reported on the forums here http://forum.openframeworks.cc/t/fixed-orientation-issues-on-ios8/20275 by @cuinjune


I'm using the latest OF 0.9.0 nightly build 20150707 for iOS development.I found some problems regarding rotation on iOS8 based on iosOrientationExample.

First, these were my settings in main.h to experiment.(if I enable 'enableHardwareOrientationAnimation' then the rotation animation didn't work properly. It just sways a little bit. I don't know why there's this setting)

settings.enableHardwareOrientation = true;   
settings.enableHardwareOrientationAnimation = false; 

With these settings, everything seemed to work well on iOS7, but I found the following issues on iOS8.

  1. When I build an app, it starts in a default orientation as it should be.
    but if I move a device a little bit(not rotating), it rotates to the current orientation unnecessarily.
  2. When I force to change the orientation using 'ofSetOrientation', It does rotate correctly from portrait to landscape mode but not from landscape to portrait mode. it still rotates, but to wrong coordinate so I could see a blank area in the top/right side of the screen.
  3. Once I force to rotate the device using 'ofSetOrientation', and then if I try rotating the device into the orientation that is already set, it should not rotate again as it is already rotated, but it rotates again.

I could fix the problem 1 and 2, but I could never fix number3. It seemed like the rotation is happening out side of ofxiOSViewController.mm. But I couldn't find where it is actually happening.

So, these are the solutions I found at least for problem 1 and 2.

  1. In ofxiOSViewController.mm file, around line127, you will find "
    - (void)rotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation".
    Inside the function, below "pendingInterfaceOrientation = interfaceOrientation;" add "currentInterfaceOrientation = pendingInterfaceOrientation;"
    I don't understand why it fixed the problem because there is already a code that does the same thing in line 216. but adding the code solved the problem anyway.

  2. Also in ofxiOSViewController.mm file, around line 166, you will find this section.

if(UIInterfaceOrientationIsLandscape(self.interfaceOrientation)) {
    center.x = screenSize.height * 0.5;
    center.y = screenSize.width * 0.5;
} else {
    center.x = screenSize.width * 0.5;
    center.y = screenSize.height * 0.5;
}

Replace the above code to the one below.

if( [[[UIDevice currentDevice] systemVersion] compare:@"8.0" options:NSNumericSearch] == NSOrderedAscending ) {
    if(UIInterfaceOrientationIsLandscape(self.interfaceOrientation)) {
        center.x = screenSize.height * 0.5;
        center.y = screenSize.width * 0.5;
    } else {
        center.x = screenSize.width * 0.5;
        center.y = screenSize.height * 0.5;
    }
} else {
    center.x = screenSize.width * 0.5;
    center.y = screenSize.height * 0.5;
}

Then it will work properly when you force to change the orientation.Now it should work well on both iOS7 and iOS8.I would appreciate if someone could fix the problem 3 for the perfection.Thanks!

@danoli3 danoli3 added the iOS label Jul 26, 2015
@danoli3 danoli3 added this to the 0.9.0 milestone Jul 26, 2015
@danoli3 danoli3 self-assigned this Jul 27, 2015
@bilderbuchi
Copy link
Member

removing the 0.9 milestone, this is not a critical bug nor a regression from 0.8.4 as far as I can see.

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

3 participants