Use following way, you make mistake in registering notification :
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationIsChanged) name:UIDeviceOrientationDidChangeNotification object:nil];
- (void) orientationIsChanged
{
if (([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeLeft) ||
([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeRight))
{
// Do your stuff for LandScape orientation
}
else if ([[UIDevice currentDevice] orientation] == UIDeviceOrientationPortrait || [[UIDevice currentDevice] orientation] == UIDeviceOrientationPortraitUpsideDown)
{
// Do your stuff for Portrait orientation
}
}
OR Simply detect as follow :
if (UIDeviceOrientationIsLandscape([[UIDevice currentDevice] orientation]))
{
// Do your stuff for LandScape orientation
}
else if (UIDeviceOrientationIsPortrait([[UIDevice currentDevice] orientation]))
{
// Do your stuff for Portrait orientation
}