1

I'm trying to do something that should be very simple, but the interface builder in xCode is doing some stuff behind the curtains that makes it all very unclear.

Basically I want to allow my OpenGL application to be orientation aware, and from what I understand I need to catch these kind of events in an UIViewController.

So, to make it simple, assuming I just created a new project using the standard MonoTouch OpenGL template, what code should I add to catch the orientation events?

Or even better, a template for starting OpenGl without the Interface Builder at all, since I am new to Interface Builder and it only seems to get in the way.

1 Answer 1

1

I am not sure if that is what you mean by "orientation aware" but you can have access to the current orientation of the device by calling the following code:

UIDeviceOrientation curOrientation = [[UIDevice currentDevice] orientation];

This will tell you whether the device orientation is Portrait, LandscapeLeft, etc. You can then rotate your views/images accordingly, depending on what you want to achieve.

Please note that UIDeviceOrientation refers to the orientation of the physical device while UIInterfaceOrientation refers to the orientation of the user interface as mentioned in this SO post:

UIDEVICE orientation

You can change the UI orientation by calling the following function:

[[UIDevice currentDevice] setOrientation:someUIInterfaceOrientation];

Hope this helps,

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.