In my app, some ViewControllers should be shown in fixed orientation but the others are free to rotate screen orientation. When I fix orientation on some ViewController using
NSNumber *value = [NSNumber NumberWithInt:UIInterfaceOrientationPortrait];
[[UIDevice currentDevice] setValue:value forKey:@"orientation"];
and this lock orientation well. However, when I back to previous ViewController or move to other ViewController which is free to rotate, orientation does not get back to real orientation.
I just release orientation lock when ViewController moves on, but [[UIDevice currentDevice] orientation]
only returns value which I set value, not current device's real orientation. [UIViewController attemptRotationToDeviceOrientation]
didn't work also.
How can I get current device's real orientation and refresh layout?
Thanks in advance.