Orientation/rotation events
Heya! I'm trying to have my prototype (iPad) app receive rotation events so that I can transform my apps' (OpenGL) visuals and touch events.
Whilst I know in theory what I should be doing - creating a UIViewController class, overriding the shouldAutorotateToInterfaceOrientation: of that class to return YES, overriding the didRotateFromInterfaceOrientation: method of that class to let the app know when a rotation event has occurred, and reading the interfaceOrientation attribute of that class for the new device rotation - it ... just doesn't seem to want to work
I created the project a while ago, with 99% of the project coming from the GLSprite example, and with the remaining 1% (the .XIB file) coming from the OpenGLES Application (iPad) template. I'm guessing that the problem is in the .XIB file - I've tried to edit that file to reflect the .XIB file from the WhichWayIsUp example (having the View become a child of the UIViewController rather than of the Window) ... but that just breaks the app (all that is rendered is a white screen and a status bar), and I have to restore the project from a back-up to undo the damage.
So I'm just wondering whether anybody can point me to a tutorial or an example which shows how to receive rotation events in the abomination of an app I've described?
Whilst I know in theory what I should be doing - creating a UIViewController class, overriding the shouldAutorotateToInterfaceOrientation: of that class to return YES, overriding the didRotateFromInterfaceOrientation: method of that class to let the app know when a rotation event has occurred, and reading the interfaceOrientation attribute of that class for the new device rotation - it ... just doesn't seem to want to work

I created the project a while ago, with 99% of the project coming from the GLSprite example, and with the remaining 1% (the .XIB file) coming from the OpenGLES Application (iPad) template. I'm guessing that the problem is in the .XIB file - I've tried to edit that file to reflect the .XIB file from the WhichWayIsUp example (having the View become a child of the UIViewController rather than of the Window) ... but that just breaks the app (all that is rendered is a white screen and a status bar), and I have to restore the project from a back-up to undo the damage.

So I'm just wondering whether anybody can point me to a tutorial or an example which shows how to receive rotation events in the abomination of an app I've described?
I had similar issues, and ended up creating a dummy view controller like this in my UIWindow subclass:
Where DummyViewController is just a UIViewController subclass, which also allows me to override - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
I'm not certain, off the top of my head whether this is what would solve your problem. It was just one of quite a few things I did in this area. But I think this was what then triggered the - (void)application:(UIApplication *)application willChangeStatusBarOrientation:(UIInterfaceOrientation)newStatusBarOrientation duration:(NSTimeInterval)duration notification to be sent when it should be to my app delegate.
Sorry it's all a bit vague, but hopefully points you in the right direction.
Code:
dummyViewController = [[DummyViewController alloc] init];
dummyViewController.view = [[UIView alloc]init];
[self addSubview:dummyViewController.view];Where DummyViewController is just a UIViewController subclass, which also allows me to override - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
I'm not certain, off the top of my head whether this is what would solve your problem. It was just one of quite a few things I did in this area. But I think this was what then triggered the - (void)application:(UIApplication *)application willChangeStatusBarOrientation:(UIInterfaceOrientation)newStatusBarOrientation duration:(NSTimeInterval)duration notification to be sent when it should be to my app delegate.
Sorry it's all a bit vague, but hopefully points you in the right direction.
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| SDL1.3/OpenGLES and iPhone Orientation | SparkyNZ | 10 | 8,788 |
Apr 13, 2011 02:38 AM Last Post: SparkyNZ |
|
| OpenGL orientation on iPad | Fred9000 | 7 | 5,713 |
Nov 27, 2010 01:21 AM Last Post: Fred9000 |
|

