Fix screen rotation

This commit is contained in:
Peter 2019-08-29 18:48:56 +04:00
parent 4ae549822a
commit 77fe3d51f1
3 changed files with 20 additions and 0 deletions

View File

@ -347,6 +347,13 @@ public func nativeWindowHostView() -> (UIWindow & WindowHost, WindowHostView, UI
rootViewController.viewDidAppear(false)
let aboveStatusbarWindow = AboveStatusBarWindow(frame: UIScreen.main.bounds)
aboveStatusbarWindow.supportedOrientations = { [weak rootViewController] in
if let rootViewController = rootViewController {
return rootViewController.supportedInterfaceOrientations
} else {
return .portrait
}
}
let hostView = WindowHostView(containerView: rootViewController.view, eventView: window, aboveStatusBarView: rootViewController.view, isRotating: {
return window.isRotating()

View File

@ -36,4 +36,6 @@ void applyKeyboardAutocorrection();
@interface AboveStatusBarWindow : UIWindow
@property (nonatomic, copy) UIInterfaceOrientationMask (^ _Nullable supportedOrientations)(void);
@end

View File

@ -311,6 +311,8 @@ void applyKeyboardAutocorrection() {
@interface AboveStatusBarWindowController : UIViewController
@property (nonatomic, copy) UIInterfaceOrientationMask (^ _Nullable supportedOrientations)(void);
@end
@implementation AboveStatusBarWindowController
@ -330,6 +332,10 @@ void applyKeyboardAutocorrection() {
[self viewDidLoad];
}
- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;
}
@end
@implementation AboveStatusBarWindow
@ -348,6 +354,11 @@ void applyKeyboardAutocorrection() {
return self;
}
- (void)setSupportedOrientations:(UIInterfaceOrientationMask (^)(void))supportedOrientations {
_supportedOrientations = [supportedOrientations copy];
((AboveStatusBarWindowController *)self.rootViewController).supportedOrientations = _supportedOrientations;
}
- (BOOL)shouldAffectStatusBarAppearance {
return false;
}