2

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.

khcpietro
  • 1,459
  • 2
  • 23
  • 42
  • Is this what you're looking for? http://stackoverflow.com/a/9122317/2976878 – Hamish Jan 18 '16 at 10:53
  • Nope. I tried this before, but it works only when device changes it's orientation. I just know "real" orientation of device without orientation changing. [[UIDevice currentDevice].orientation] returns only value which I set programmatically. – khcpietro Jan 18 '16 at 21:15

0 Answers0