Hey guys,
I had this issue too, and I think it comes from the fact that when the iPad is face up or facedown, the iPad generates three notifications in quick succession. (For example, UIInterfaceOrientationLandscapeLeft, UIInterfaceOrientationFaceUp, UIInterfaceOrientationLandscapeLeft.)
Here's how I solved this:
First, I register the app to recieve orientationChanged notifications. I don't start the app in "applicationDidFinishLaunching".
- (void) applicationDidFinishLaunching:(UIApplication*)application
{
// CC_DIRECTOR_INIT()
//
// 1. Initializes an EAGLView with 0-bit depth format, and RGB565 render buffer
// 2. EAGLView multiple touches: disabled
// 3. creates a UIWindow, and assign it to the "window" var (it must already be declared)
// 4. Parents EAGLView to the newly created window
// 5. Creates Display Link Director
// 5a. If it fails, it will use an NSTimer director
// 6. It will try to run at 60 FPS
// 7. Display FPS: NO
// 8. Device orientation: Portrait
// 9. Connects the director to the EAGLView
//
CC_DIRECTOR_INIT();
// Obtain the shared director in order to...
CCDirector *director = [CCDirector sharedDirector];
// Turn on display FPS
[director setDisplayFPS:NO];
[director setAnimationInterval:1.0/240.0];
// Turn on multiple touches
EAGLView *view = [director openGLView];
[view setMultipleTouchEnabled:YES];
// Default texture format for PNG/BMP/TIFF/JPEG/GIF images
// It can be RGBA8888, RGBA4444, RGB5_A1, RGB565
// You can change anytime.
[CCTexture2D setDefaultAlphaPixelFormat:kTexture2DPixelFormat_RGBA8888];
//other initialization code...
//register for the orientation changed method
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(orientationChanged:)
name:@"UIDeviceOrientationDidChangeNotification"
object:nil];
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
}
Here's my orientationChanged method:
-(void) orientationChanged:(NSNotification *)notification {
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
UIInterfaceOrientation orientation = [[UIDevice currentDevice] orientation];
if (orientation == UIDeviceOrientationPortrait ||
orientation == UIDeviceOrientationPortraitUpsideDown ||
orientation == UIDeviceOrientationLandscapeLeft ||
orientation == UIDeviceOrientationLandscapeRight)
{
if ([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeRight)
[[CCDirector sharedDirector] setDeviceOrientation:CCDeviceOrientationLandscapeRight];
else
[[CCDirector sharedDirector] setDeviceOrientation:CCDeviceOrientationLandscapeLeft];
[[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] removeObserver:self
name:@"UIDeviceOrientationDidChangeNotification"
object:nil];
[self finishIPadInit];
}
}
}
finishIPadInit actually takes care of the loading for me. Hope this helps!