openframeworks / openframeworks/openFrameworks
Orientation issues in iOS 8
@danoli3 is already working on this.
Since Jul 27, 2015.
- Dominant language
- C++
- Stars
- 10.4k
- Forks
- 2.6k
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 9
Description
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.
- 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.- 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.
- 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.
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.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!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.