Skip to content

Commit 45a52c7

Browse files
javachefacebook-github-bot-8
authored andcommitted
Support multiple interface orientations in RCTDevLoadingView
Summary: When rotating on iPad, the dev loading view just looks clowny since it doesn't rotate properly. Reviewed By: majak Differential Revision: D2939721 fb-gh-sync-id: 7f1926f5cee4761cde8881e9387ae6e0063c5d6c shipit-source-id: 7f1926f5cee4761cde8881e9387ae6e0063c5d6c
1 parent f51c16b commit 45a52c7

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

React/Modules/RCTDevLoadingView.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#import "RCTDevLoadingView.h"
1414
#import "RCTDefines.h"
1515
#import "RCTUtils.h"
16+
#import "RCTModalHostViewController.h"
1617

1718
#if RCT_DEV
1819

@@ -68,6 +69,9 @@ - (void)setBridge:(RCTBridge *)bridge
6869
_window = [[UIWindow alloc] initWithFrame:CGRectMake(0, 0, screenWidth, 22)];
6970
_window.windowLevel = UIWindowLevelStatusBar + 1;
7071

72+
// set a root VC so rotation is supported
73+
_window.rootViewController = [RCTModalHostViewController new];
74+
7175
_label = [[UILabel alloc] initWithFrame:_window.bounds];
7276
_label.font = [UIFont systemFontOfSize:12.0];
7377
_label.textAlignment = NSTextAlignmentCenter;

React/Views/RCTModalHostViewController.m

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,14 @@ - (void)viewDidLayoutSubviews
2424
}
2525
}
2626

27+
- (UIInterfaceOrientationMask)supportedInterfaceOrientations
28+
{
29+
// Picking some defaults here, we should probably make this configurable
30+
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
31+
return UIInterfaceOrientationMaskAll;
32+
} else {
33+
return UIInterfaceOrientationMaskPortrait;
34+
}
35+
}
36+
2737
@end

0 commit comments

Comments
 (0)