Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Gettin my app to autorotate

My app got rejected for not autorotating so I am trying to implement that now.

My app is a painting application based off GLPaint. The problem with this is that there is no ViewController class and that is where this code is found that does the autorotation:


-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceO rientation {
// Return YES for supported orientations
return YES;
}

So since I dont have this class only a AppController and PaintingView, where do I implement this code. Is it possible to create a view controller and have it link up to control my MainWindow.xib?

If not, then how can I make my app autorotate. Thank you.

MacBook Pro, Mac OS X (10.5.6)

Posted on Apr 5, 2010 3:25 AM

Reply
13 replies

Apr 5, 2010 4:16 AM in response to GabeJ

You can be informed of the Device Orientation Changes, then you'll have to manage the layout and drawing of your view according to the interface orientation

You have to activate the Device Orientation notifications

UIDevice *device = [UIDevice currentDevice];
[device beginGeneratingDeviceOrientationNotifications];

Then you have to subscribe to these notifications, for example :

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

Apr 5, 2010 12:36 PM in response to K T

I was just trying to get a broad area of responses because there did not seems to be much about this specific problem on the web.

About your response on the dev forums, the problem with this is that I have no where to put that code because I do not have a viewcontroller in the app. It's the view controller that has that function. This is my problem...

Jun 16, 2010 5:36 AM in response to K T

OK. I am assuming that you are using the OpenGLES Template iPad application to start your project. Why Apple choose to make it look like it does is beyond me, but there you go.

What you need to do is start a View based application, and then copy in the opengl parts of the opengles template project into the view based project. Then in the ViewDidLoad function, you need to create an instance of your OpenGLES View (EAGLView or something like that). You then have an autorotating OpenGLES project. Yay.

There are other issues with doing this, but with a simple project it should be fine. If, like me, you want to run the OpenGL updates in a thread, it then becomes a world of pain, with everything being initialised at the wrong times and crashing in openGL functions etc.... but for what you are doing, this will work perfectly !

Haven't got the code to hand at the moment, but if you look on the web, there should be examples like this.

Gettin my app to autorotate

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.