1212
1313#define LTHiOS8 ([[[UIDevice currentDevice ] systemVersion ] compare: @" 8.0" \
1414options: NSNumericSearch] != NSOrderedAscending)
15- #define LTHiPad (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
15+ #define LTHiPad ([[UIDevice currentDevice ] userInterfaceIdiom ] == UIUserInterfaceIdiomPad)
1616
1717#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000
1818#define LTHFailedAttemptLabelHeight [_failedAttemptLabel.text sizeWithAttributes: @{NSFontAttributeName : _labelFont}].height
@@ -569,13 +569,13 @@ - (void)_dismissMe {
569569 self.view .center = CGPointMake (self.view .center .x , self.view .center .y * 2 .f );
570570 }
571571 else {
572- if ([UIApplication sharedApplication ]. statusBarOrientation == UIInterfaceOrientationLandscapeLeft) {
572+ if ([LTHPasscodeViewController currentOrientation ] == UIInterfaceOrientationLandscapeLeft) {
573573 self.view .center = CGPointMake (self.view .center .x * -1 .f , self.view .center .y );
574574 }
575- else if ([UIApplication sharedApplication ]. statusBarOrientation == UIInterfaceOrientationLandscapeRight) {
575+ else if ([LTHPasscodeViewController currentOrientation ] == UIInterfaceOrientationLandscapeRight) {
576576 self.view .center = CGPointMake (self.view .center .x * 2 .f , self.view .center .y );
577577 }
578- else if ([UIApplication sharedApplication ]. statusBarOrientation == UIInterfaceOrientationPortrait) {
578+ else if ([LTHPasscodeViewController currentOrientation ] == UIInterfaceOrientationPortrait) {
579579 self.view .center = CGPointMake (self.view .center .x , self.view .center .y * -1 .f );
580580 }
581581 else {
@@ -1056,17 +1056,17 @@ - (void)showLockScreenOver:(UIView *)superview withAnimation:(BOOL)animated with
10561056 superviewCenter.y + self.navigationController .navigationBar .frame .size .height / 2 );
10571057 }
10581058 else {
1059- if ([UIApplication sharedApplication ]. statusBarOrientation == UIInterfaceOrientationLandscapeLeft) {
1059+ if ([LTHPasscodeViewController currentOrientation ] == UIInterfaceOrientationLandscapeLeft) {
10601060 self.view .center = CGPointMake (self.view .center .x * -1 .f , self.view .center .y );
10611061 newCenter = CGPointMake (superviewCenter.x - self.navigationController .navigationBar .frame .size .height / 2 ,
10621062 superviewCenter.y );
10631063 }
1064- else if ([UIApplication sharedApplication ]. statusBarOrientation == UIInterfaceOrientationLandscapeRight) {
1064+ else if ([LTHPasscodeViewController currentOrientation ] == UIInterfaceOrientationLandscapeRight) {
10651065 self.view .center = CGPointMake (self.view .center .x * 2 .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 == UIInterfaceOrientationPortrait) {
1069+ else if ([LTHPasscodeViewController currentOrientation ] == UIInterfaceOrientationPortrait) {
10701070 self.view .center = CGPointMake (self.view .center .x , self.view .center .y * -1 .f );
10711071 newCenter = CGPointMake (superviewCenter.x ,
10721072 superviewCenter.y - self.navigationController .navigationBar .frame .size .height / 2 );
@@ -1108,6 +1108,7 @@ - (void)_prepareNavigationControllerWithController:(UIViewController *)viewContr
11081108 }
11091109 UINavigationController *navController =
11101110 [[UINavigationController alloc ] initWithRootViewController: self ];
1111+ navController.modalPresentationStyle = UIModalPresentationFullScreen;
11111112
11121113 // Make sure nav bar for logout is off the screen
11131114 [self .navBar removeFromSuperview ];
@@ -1790,6 +1791,28 @@ - (void)_addObservers {
17901791
17911792
17921793#pragma mark - Handling rotation
1794+
1795+ // Internal method for fetching the current orientation
1796+ + (UIInterfaceOrientation)currentOrientation
1797+ {
1798+ // statusBarOrientation is deprecated in iOS 13 and windowScene isn't available before iOS 13
1799+ #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
1800+ if (@available (iOS 13.0 , *))
1801+ {
1802+ return LTHMainWindow.windowScene .interfaceOrientation ;
1803+ }
1804+ else
1805+ {
1806+ #pragma clang diagnostic push
1807+ #pragma clang diagnostic ignored "-Wdeprecated-declarations"
1808+ #endif
1809+ return [[UIApplication sharedApplication ] statusBarOrientation ];
1810+ #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
1811+ #pragma clang diagnostic pop
1812+ }
1813+ #endif
1814+ }
1815+
17931816- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
17941817 if (_displayedAsLockScreen)
17951818 return LTHiOS8 ? UIInterfaceOrientationMaskPortrait : UIInterfaceOrientationMaskAll;
@@ -1814,7 +1837,7 @@ - (void)statusBarFrameOrOrientationChanged:(NSNotification *)notification {
18141837 _animatingView.frame = self.view .bounds ;
18151838 }
18161839 else {
1817- if (UIInterfaceOrientationIsPortrait ([UIApplication sharedApplication ]. statusBarOrientation )) {
1840+ if (UIInterfaceOrientationIsPortrait ([LTHPasscodeViewController currentOrientation ] )) {
18181841 _animatingView.frame = CGRectMake (0 , 0 , LTHMainWindow.frame .size .width , LTHMainWindow.frame .size .height );
18191842 }
18201843 else {
@@ -1829,8 +1852,7 @@ - (void)statusBarFrameOrOrientationChanged:(NSNotification *)notification {
18291852// then presenting it inside a modal in another orientation would display
18301853// the view in the first orientation.
18311854- (UIInterfaceOrientation)desiredOrientation {
1832- UIInterfaceOrientation statusBarOrientation =
1833- [[UIApplication sharedApplication ] statusBarOrientation ];
1855+ UIInterfaceOrientation statusBarOrientation = [LTHPasscodeViewController currentOrientation ];
18341856 UIInterfaceOrientationMask statusBarOrientationAsMask = UIInterfaceOrientationMaskFromOrientation (statusBarOrientation);
18351857 if (self.supportedInterfaceOrientations & statusBarOrientationAsMask) {
18361858 return statusBarOrientation;
@@ -1900,13 +1922,34 @@ - (void)enablePasscodeWhenApplicationEntersBackground {
19001922
19011923
19021924+ (CGFloat)getStatusBarHeight {
1903- UIInterfaceOrientation orientation = [UIApplication sharedApplication ].statusBarOrientation ;
1904- if (UIInterfaceOrientationIsLandscape (orientation)) {
1905- return [UIApplication sharedApplication ].statusBarFrame .size .width ;
1925+ UIInterfaceOrientation orientation = [LTHPasscodeViewController currentOrientation ];
1926+
1927+ // statusBarFrame is deprecated in iOS 13 and windowScene isn't available before iOS 13
1928+ #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
1929+ if (@available (iOS 13.0 , *))
1930+ {
1931+ if (UIInterfaceOrientationIsLandscape (orientation)) {
1932+ return LTHMainWindow.windowScene .statusBarManager .statusBarFrame .size .width ;
1933+ }
1934+ else {
1935+ return LTHMainWindow.windowScene .statusBarManager .statusBarFrame .size .height ;
1936+ }
19061937 }
1907- else {
1908- return [UIApplication sharedApplication ].statusBarFrame .size .height ;
1938+ else
1939+ {
1940+ #pragma clang diagnostic push
1941+ #pragma clang diagnostic ignored "-Wdeprecated-declarations"
1942+ #endif
1943+ if (UIInterfaceOrientationIsLandscape (orientation)) {
1944+ return [UIApplication sharedApplication ].statusBarFrame .size .width ;
1945+ }
1946+ else {
1947+ return [UIApplication sharedApplication ].statusBarFrame .size .height ;
1948+ }
1949+ #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
1950+ #pragma clang diagnostic pop
19091951 }
1952+ #endif
19101953}
19111954
19121955
0 commit comments