Hardware Orientation on startup for iOS with OF Develop

I have been checking out the great updates in the dev branch of OF for iOS. I know it constantly is receiving updates, but I would really like to use the hardware rotation update included in this branch.

I checked out the iosOrientationExample and it works great, but only after rotating the device once. If you launch the application in landscape mode, then it does not orient correctly.

Anyone else having the same issue or have any ideas?

Thanks
Nick

I have the same issue, only can use portrait orientation (in xcode)+ ofxiPhoneSetOrientation(OFXIPHONE_ORIENTATION_LANDSCAPE_RIGHT) (in testApp::setup()) to make landscape happen.

I tried many ways to solve it, but not get any luck, hope someone can explain this.

have you tried latest/current develop? there have been quite many changes/fixes very recently, also for ios orientation issues.

Hi bilderbuchi,

what do you mean current develop? I use OF 0.7.4, is it the current one?
If not, can you give me a link?

bilderbuchi is referring to the develop branch on github.
https://github.com/openframeworks/openFrameworks/tree/develop
If you don’t have git installed on your computer, you can download the zip file from github using the download button on the page.
There is a nice hardware orientation example included.
https://github.com/openframeworks/openFrameworks/tree/develop/examples/ios/iosOrientationExample

To enable hardware orientation
call enableHardwareOrientation() on the iosWindow
https://github.com/openframeworks/openFrameworks/blob/develop/examples/ios/iosOrientationExample/src/main.mm#L7-L8

If you would like the device to change to the current orientation you must have this function defined and call ofSetOrientation
https://github.com/openframeworks/openFrameworks/blob/develop/examples/ios/iosOrientationExample/src/testApp.mm#L195-L199

Make sure to select the appropriate ‘Supported Device Orientations’ (see attached image).

![](http://forum.openframeworks.cc/uploads/default/2989/Screen Shot 2013-08-07 at 8.41.53 PM.png)

Hi NickHardeman,

I tried hardware orientation example, it worked very well. But it only works on newest OF that means I can’t use some addons I can use on OF 0.7.4., is there any way I can have hardware orientation in OF0.7.4?

If you just want to deal with the cropping issues, in the autorotation in 0074

go inside

openFrameworks / addons / ofxiPhone / src / core / ofxiPhoneViewController.mm

inside:

  • (id)initWithFrame:(CGRect)frame app:(ofxiPhoneApp *)app {

before or
after

[self.view addSubview:self.glView];

add:

** self.glView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
**

This will autorotate, but on some devices it will cause a weird ugly “blinking” issue before everyRotation…