@@ -574,13 +574,13 @@ - (void)_dismissMe {
574574 self.view .center = CGPointMake (self.view .center .x , self.view .center .y * 2 .f );
575575 }
576576 else {
577- if ([UIApplication sharedApplication ]. statusBarOrientation == UIInterfaceOrientationLandscapeLeft) {
577+ if ([LTHPasscodeViewController currentOrientation ] == UIInterfaceOrientationLandscapeLeft) {
578578 self.view .center = CGPointMake (self.view .center .x * -1 .f , self.view .center .y );
579579 }
580- else if ([UIApplication sharedApplication ]. statusBarOrientation == UIInterfaceOrientationLandscapeRight) {
580+ else if ([LTHPasscodeViewController currentOrientation ] == UIInterfaceOrientationLandscapeRight) {
581581 self.view .center = CGPointMake (self.view .center .x * 2 .f , self.view .center .y );
582582 }
583- else if ([UIApplication sharedApplication ]. statusBarOrientation == UIInterfaceOrientationPortrait) {
583+ else if ([LTHPasscodeViewController currentOrientation ] == UIInterfaceOrientationPortrait) {
584584 self.view .center = CGPointMake (self.view .center .x , self.view .center .y * -1 .f );
585585 }
586586 else {
@@ -1061,17 +1061,17 @@ - (void)showLockScreenOver:(UIView *)superview withAnimation:(BOOL)animated with
10611061 superviewCenter.y + self.navigationController .navigationBar .frame .size .height / 2 );
10621062 }
10631063 else {
1064- if ([UIApplication sharedApplication ]. statusBarOrientation == UIInterfaceOrientationLandscapeLeft) {
1064+ if ([LTHPasscodeViewController currentOrientation ] == UIInterfaceOrientationLandscapeLeft) {
10651065 self.view .center = CGPointMake (self.view .center .x * -1 .f , self.view .center .y );
10661066 newCenter = CGPointMake (superviewCenter.x - self.navigationController .navigationBar .frame .size .height / 2 ,
10671067 superviewCenter.y );
10681068 }
1069- else if ([UIApplication sharedApplication ]. statusBarOrientation == UIInterfaceOrientationLandscapeRight) {
1069+ else if ([LTHPasscodeViewController currentOrientation ] == UIInterfaceOrientationLandscapeRight) {
10701070 self.view .center = CGPointMake (self.view .center .x * 2 .f , self.view .center .y );
10711071 newCenter = CGPointMake (superviewCenter.x + self.navigationController .navigationBar .frame .size .height / 2 ,
10721072 superviewCenter.y );
10731073 }
1074- else if ([UIApplication sharedApplication ]. statusBarOrientation == UIInterfaceOrientationPortrait) {
1074+ else if ([LTHPasscodeViewController currentOrientation ] == UIInterfaceOrientationPortrait) {
10751075 self.view .center = CGPointMake (self.view .center .x , self.view .center .y * -1 .f );
10761076 newCenter = CGPointMake (superviewCenter.x ,
10771077 superviewCenter.y - self.navigationController .navigationBar .frame .size .height / 2 );
@@ -1795,6 +1795,28 @@ - (void)_addObservers {
17951795
17961796
17971797#pragma mark - Handling rotation
1798+
1799+ // Internal method for fetching the current orientation
1800+ + (UIInterfaceOrientation)currentOrientation
1801+ {
1802+ // statusBarOrientation is deprecated in iOS 13 and windowScene isn't available before iOS 13
1803+ #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
1804+ if (@available (iOS 13.0 , *))
1805+ {
1806+ return LTHMainWindow.windowScene .interfaceOrientation ;
1807+ }
1808+ else
1809+ {
1810+ #pragma clang diagnostic push
1811+ #pragma clang diagnostic ignored "-Wdeprecated-declarations"
1812+ #endif
1813+ return [[UIApplication sharedApplication ] statusBarOrientation ];
1814+ #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
1815+ #pragma clang diagnostic pop
1816+ }
1817+ #endif
1818+ }
1819+
17981820- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
17991821 if (_displayedAsLockScreen)
18001822 return LTHiOS8 ? UIInterfaceOrientationMaskPortrait : UIInterfaceOrientationMaskAll;
@@ -1819,7 +1841,7 @@ - (void)statusBarFrameOrOrientationChanged:(NSNotification *)notification {
18191841 _animatingView.frame = self.view .bounds ;
18201842 }
18211843 else {
1822- if (UIInterfaceOrientationIsPortrait ([UIApplication sharedApplication ]. statusBarOrientation )) {
1844+ if (UIInterfaceOrientationIsPortrait ([LTHPasscodeViewController currentOrientation ] )) {
18231845 _animatingView.frame = CGRectMake (0 , 0 , LTHMainWindow.frame .size .width , LTHMainWindow.frame .size .height );
18241846 }
18251847 else {
@@ -1834,8 +1856,7 @@ - (void)statusBarFrameOrOrientationChanged:(NSNotification *)notification {
18341856// then presenting it inside a modal in another orientation would display
18351857// the view in the first orientation.
18361858- (UIInterfaceOrientation)desiredOrientation {
1837- UIInterfaceOrientation statusBarOrientation =
1838- [[UIApplication sharedApplication ] statusBarOrientation ];
1859+ UIInterfaceOrientation statusBarOrientation = [LTHPasscodeViewController currentOrientation ];
18391860 UIInterfaceOrientationMask statusBarOrientationAsMask = UIInterfaceOrientationMaskFromOrientation (statusBarOrientation);
18401861 if (self.supportedInterfaceOrientations & statusBarOrientationAsMask) {
18411862 return statusBarOrientation;
@@ -1905,7 +1926,7 @@ - (void)enablePasscodeWhenApplicationEntersBackground {
19051926
19061927
19071928+ (CGFloat)getStatusBarHeight {
1908- UIInterfaceOrientation orientation = [UIApplication sharedApplication ]. statusBarOrientation ;
1929+ UIInterfaceOrientation orientation = [LTHPasscodeViewController currentOrientation ] ;
19091930 if (UIInterfaceOrientationIsLandscape (orientation)) {
19101931 return [UIApplication sharedApplication ].statusBarFrame .size .width ;
19111932 }
0 commit comments