Reputation: 5955
on iPad ios 9+, with objective-c : - lock the orientation outside of your app - in code: how to detect when the device changes the orientation?
I have tried all possibilities:
1) try to catch UIDeviceOrientationDidChangeNotification event:
- (void)subscribeOrientationChangeEvent { [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged:) name:UIDeviceOrientationDidChangeNotification object:[UIDevice currentDevice]]; } - (void) orientationChanged:(NSNotification *)note { NSLog("Device rotated"); }
2) override viewWillTransitionToSize method
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id)coordinator { [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator]; NSLog("Device rotated"); }
3) use KVO to see if the value orientation of [UIDevice currentDevie]
4) use KVO to see if the value statusBarOrientation of [UIApplication sharedApplication]
5) set Require FullScreen for the setting StatusBarStyle
reference: link
apply this setting and combine with all above attempts, but all failed.
Any advice? thanks a lot
Upvotes: 1
Views: 962
Reputation: 7370
If the device orientation is lock; your app will have to abide by it. You won't be able to detect orientation for obvious reasons. So the short answer is you can't.
Upvotes: 0