PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Iphone Orientation Issue

Hello,

I am a new user of the EdgeLib, and I want to use it to make some iPad applications.
An iPad application must support at least 2 orientations to be validated and submitted.

So, I want to know how to rotate the application when the device's orientation change.

I have try many things :
- Use the callback OnDisplayChange, try to printf something inside, but this method's never called, so I don't understand what's the use of this callback.
- create a new class (.mm) and a method which check the UIDevice orientation. I call this method every frame (OnNextFrame), but the orientation of UIDevice never changes.
- I also try to add some options in the Info.plist as UISupportedInterfaceOrientations etc.. but nothing.

So what is the correct method to handle the orientation's change event?

Thanks in advance,

Raymond
Hi Raymond,

The OnDeviceChanged callback is used for other mobile platforms and has no use for iPhone. We will research orientation handling on the iPad in combination EDGELIB. Either way, when using OpenGL ES you need to manually rotate (using glRotate and glTranslate) for orientations other than portrait mode.
Hi, thanks for your answer.

I agree, but my problem is the handling of the orientation's change event.
I don't know how to know when does the user move his device to other orientation!

I find some ways to rotate the screen manually (as you said), but no way to know when to do it !

Some applications (angry birds) developped with edgelib manage perfectly the rotation, so it is possible.

I don't know if I am clear..

Please help me!

Thanks
The app probably monitors the accelerometer.
Hi Raymond,

To get orientation events you need to register a callback function from the notification center:
Code:

[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationDidChange:) name:UIDeviceOrientationDidChangeNotification object:nil];


And finally, implement the callback:
Code:

//Orientation change callback
- (void)orientationDidChange:(NSNotification *)notification
{
UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
//Handle orientation event
}
Could you make a short tutorial about that ? That would be greatly appreciated.
Also, is there any chance this feature would be integrated in an upcoming release ?
Thanks!
Hi,

The above two functions are written in Objective-C and can be implemented in your application. To do this, create an .mm source file with these functions inside (these can be part of a C++ class). The header file can be included in your c++ program, as long as there is no objective-c code inside that header file.

We may choose to implement a more convenient way of handling this in a future version of EDGELIB, however this isn't planned yet.