All you have to do is the following:
In didfinishlaunching write
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didRotate:) name:UIDeviceOrientationDidChangeNotification object:nil];
and then copy the following callback method
- (void) didRotate:(NSNotification *)notification { UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation]; if (orientation == UIDeviceOrientationLandscapeLeft) { NSLog(@"Landscape Left!"); self.isLandscapeLeft=1; }else if(orientation == UIDeviceOrientationLandscapeRight){ NSLog(@"Landscape Right!"); self.isLandscapeLeft=0; } }
In the same way, you can check the orientation for the wipe mode, face up, face down, upside down, as well as landscape and landscape orientation. :)
Shantanu
source share