Я только что исправил это в своем приложении под iOS 5.1.Это старый вопрос, но я оставляю это здесь для потомков, так как я не видел, чтобы кто-нибудь еще решал это без применения кусков кода CGAffineTransform и не исправляя реальную проблему, которая заключается в том, что UIInterfaceOrientation и UIDeviceOrientation не синхронизированы.
В моем случае мне нужно было только исправить ориентацию, когда я переходил из ViewController, работающего только в портретной ориентации, и в ViewController, работающий в вертикальной и горизонтальной ориентации, когда устройство было физически повернуто до перехода.
// The "Interface Orientation" and the "Device Orientation" can become separated in some cases.
// Make sure the view controller only supports the interface orientation for the current device rotation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
int deviceRotation = [[UIDevice currentDevice] orientation];
[[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications];
if (deviceRotation == UIDeviceOrientationUnknown ||
deviceRotation == UIDeviceOrientationFaceUp ||
deviceRotation == UIDeviceOrientationFaceDown)
return YES;
if (deviceRotation != interfaceOrientation)
return NO;
else
return YES;
}