|
49 | 49 | Any help would be greatly appreciated. |
50 | 50 | */ |
51 | 51 |
|
| 52 | +#if defined(LTH_APP_EXTENSIONS) |
| 53 | +#define LTHMainWindow [UIApplication sharedApplication].keyWindow |
| 54 | +#else |
52 | 55 | #define LTHMainWindow [UIApplication sharedApplication].windows[0] |
| 56 | +#endif |
53 | 57 |
|
54 | 58 | @interface LTHPasscodeViewController () <UITextFieldDelegate> |
55 | 59 | @property (nonatomic, strong) UIView *coverView; |
@@ -1005,47 +1009,51 @@ - (void)showLockscreenWithoutAnimation { |
1005 | 1009 | [self showLockScreenWithAnimation:NO withLogout:NO andLogoutTitle:nil]; |
1006 | 1010 | } |
1007 | 1011 |
|
1008 | | - |
1009 | 1012 | - (void)showLockScreenWithAnimation:(BOOL)animated withLogout:(BOOL)hasLogout andLogoutTitle:(NSString*)logoutTitle { |
| 1013 | + [self showLockScreenOver:LTHMainWindow withAnimation:animated withLogout:hasLogout andLogoutTitle:logoutTitle]; |
| 1014 | +} |
| 1015 | + |
| 1016 | +- (void)showLockScreenOver:(UIView *)superview withAnimation:(BOOL)animated withLogout:(BOOL)hasLogout andLogoutTitle:(NSString*)logoutTitle { |
1010 | 1017 | [self _prepareAsLockScreen]; |
1011 | 1018 |
|
1012 | 1019 | // In case the user leaves the app while the lockscreen is already active. |
1013 | 1020 | if (_isCurrentlyOnScreen) { return; } |
1014 | 1021 | _isCurrentlyOnScreen = YES; |
1015 | 1022 |
|
1016 | | - [LTHMainWindow addSubview: self.view]; |
| 1023 | + [superview addSubview: self.view]; |
1017 | 1024 |
|
1018 | 1025 | // All this hassle because a view added to UIWindow does not rotate automatically |
1019 | 1026 | // and if we would have added the view anywhere else, it wouldn't display properly |
1020 | 1027 | // (having a modal on screen when the user leaves the app, for example). |
1021 | 1028 | [self rotateAccordingToStatusBarOrientationAndSupportedOrientations]; |
| 1029 | + CGPoint superviewCenter = CGPointMake(superview.center.x, superview.center.y); |
1022 | 1030 | CGPoint newCenter; |
1023 | 1031 | [self statusBarFrameOrOrientationChanged:nil]; |
1024 | 1032 | if (LTHiOS8) { |
1025 | 1033 | self.view.center = CGPointMake(self.view.center.x, self.view.center.y * -1.f); |
1026 | | - newCenter = CGPointMake(LTHMainWindow.center.x, |
1027 | | - LTHMainWindow.center.y + self.navigationController.navigationBar.frame.size.height / 2); |
| 1034 | + newCenter = CGPointMake(superviewCenter.x, |
| 1035 | + superviewCenter.y + self.navigationController.navigationBar.frame.size.height / 2); |
1028 | 1036 | } |
1029 | 1037 | else { |
1030 | 1038 | if ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeLeft) { |
1031 | 1039 | self.view.center = CGPointMake(self.view.center.x * -1.f, self.view.center.y); |
1032 | | - newCenter = CGPointMake(LTHMainWindow.center.x - self.navigationController.navigationBar.frame.size.height / 2, |
1033 | | - LTHMainWindow.center.y); |
| 1040 | + newCenter = CGPointMake(superviewCenter.x - self.navigationController.navigationBar.frame.size.height / 2, |
| 1041 | + superviewCenter.y); |
1034 | 1042 | } |
1035 | 1043 | else if ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeRight) { |
1036 | 1044 | self.view.center = CGPointMake(self.view.center.x * 2.f, self.view.center.y); |
1037 | | - newCenter = CGPointMake(LTHMainWindow.center.x + self.navigationController.navigationBar.frame.size.height / 2, |
1038 | | - LTHMainWindow.center.y); |
| 1045 | + newCenter = CGPointMake(superviewCenter.x + self.navigationController.navigationBar.frame.size.height / 2, |
| 1046 | + superviewCenter.y); |
1039 | 1047 | } |
1040 | 1048 | else if ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPortrait) { |
1041 | 1049 | self.view.center = CGPointMake(self.view.center.x, self.view.center.y * -1.f); |
1042 | | - newCenter = CGPointMake(LTHMainWindow.center.x, |
1043 | | - LTHMainWindow.center.y - self.navigationController.navigationBar.frame.size.height / 2); |
| 1050 | + newCenter = CGPointMake(superviewCenter.x, |
| 1051 | + superviewCenter.y - self.navigationController.navigationBar.frame.size.height / 2); |
1044 | 1052 | } |
1045 | 1053 | else { |
1046 | 1054 | self.view.center = CGPointMake(self.view.center.x, self.view.center.y * 2.f); |
1047 | | - newCenter = CGPointMake(LTHMainWindow.center.x, |
1048 | | - LTHMainWindow.center.y + self.navigationController.navigationBar.frame.size.height / 2); |
| 1055 | + newCenter = CGPointMake(superviewCenter.x, |
| 1056 | + superviewCenter.y + self.navigationController.navigationBar.frame.size.height / 2); |
1049 | 1057 | } |
1050 | 1058 | } |
1051 | 1059 |
|
@@ -1834,12 +1842,12 @@ - (void)rotateAccordingToStatusBarOrientationAndSupportedOrientations { |
1834 | 1842 | CGFloat angle = UIInterfaceOrientationAngleOfOrientation(orientation); |
1835 | 1843 | CGAffineTransform transform = CGAffineTransformMakeRotation(angle); |
1836 | 1844 |
|
1837 | | - [self setIfNotEqualTransform: transform |
1838 | | - frame: self.view.window.bounds]; |
| 1845 | + [self setIfNotEqualTransform: transform]; |
1839 | 1846 | } |
1840 | 1847 |
|
1841 | 1848 |
|
1842 | | -- (void)setIfNotEqualTransform:(CGAffineTransform)transform frame:(CGRect)frame { |
| 1849 | +- (void)setIfNotEqualTransform:(CGAffineTransform)transform { |
| 1850 | + CGRect frame = self.view.superview.frame; |
1843 | 1851 | if(!CGAffineTransformEqualToTransform(self.view.transform, transform)) { |
1844 | 1852 | self.view.transform = transform; |
1845 | 1853 | } |
|
0 commit comments