diff --git a/React/CoreModules/RCTLogBox.mm b/React/CoreModules/RCTLogBox.mm index 4faa4a2db84..1e89ce1c849 100644 --- a/React/CoreModules/RCTLogBox.mm +++ b/React/CoreModules/RCTLogBox.mm @@ -29,18 +29,18 @@ @class RCTLogBoxView; -@interface RCTLogBoxView : UIView +@interface RCTLogBoxView : UIWindow @end @implementation RCTLogBoxView { - UIViewController *_rootViewController; RCTSurface *_surface; } - (instancetype)initWithFrame:(CGRect)frame bridge:(RCTBridge *)bridge { if ((self = [super initWithFrame:frame])) { + self.windowLevel = UIWindowLevelStatusBar - 1; self.backgroundColor = [UIColor clearColor]; _surface = [[RCTSurface alloc] initWithBridge:bridge moduleName:@"LogBox" initialProperties:@{}]; @@ -52,31 +52,24 @@ RCTLogInfo(@"Failed to mount LogBox within 1s"); } - _rootViewController = [UIViewController new]; + UIViewController *_rootViewController = [UIViewController new]; _rootViewController.view = (UIView *)_surface.view; _rootViewController.view.backgroundColor = [UIColor clearColor]; _rootViewController.modalPresentationStyle = UIModalPresentationFullScreen; + self.rootViewController = _rootViewController; } return self; } - (void)dealloc { - // Dismiss by deallocating the window. - // This will also handle JS reload, otherwise the LogBox view would be stuck on top. - [_rootViewController.view resignFirstResponder]; - [_rootViewController dismissViewControllerAnimated:NO completion:NULL]; + [RCTSharedApplication().delegate.window makeKeyWindow]; } - (void)show { - __weak __typeof(self) weakSelf = self; - [RCTSharedApplication().delegate.window.rootViewController presentViewController:_rootViewController animated:NO completion:^{ - __strong __typeof(self) strongSelf = weakSelf; - if (strongSelf) { - [strongSelf->_rootViewController.view becomeFirstResponder]; - } - }]; + [self becomeFirstResponder]; + [self makeKeyAndVisible]; } @end