Warn when displaying a modal with unsupported interface orientations

Summary: In dev mode, this removes all iOS crashes from specifying the incorrect interface orientations. It also includes okay-ish instructions for how to fix the problem.

Reviewed By: fkgozali

Differential Revision: D3904998

fbshipit-source-id: 699599fa77fd87e6615436250e38944e577e75a0
This commit is contained in:
Mehdi Mulani 2016-09-22 12:46:29 -07:00 committed by Facebook Github Bot
parent bdc47313e8
commit 858e95b2aa
1 changed files with 18 additions and 0 deletions

View File

@ -9,6 +9,7 @@
#import "RCTModalHostViewController.h"
#import "RCTLog.h"
#import "RCTModalHostView.h"
@implementation RCTModalHostViewController
@ -50,4 +51,21 @@
return _preferredStatusBarHidden;
}
#if RCT_DEV
- (UIInterfaceOrientationMask)supportedInterfaceOrientations
{
UIInterfaceOrientationMask appSupportedOrientationsMask = [[UIApplication sharedApplication] supportedInterfaceOrientationsForWindow:[[UIApplication sharedApplication] keyWindow]];
if (!(_supportedInterfaceOrientations & appSupportedOrientationsMask)) {
RCTLogError(@"Modal was presented with 0x%x orientations mask but the application only supports 0x%x."
@"Add more interface orientations to your app's Info.plist to fix this."
@"NOTE: This will crash in non-dev mode.",
(unsigned)_supportedInterfaceOrientations,
(unsigned)appSupportedOrientationsMask);
return UIInterfaceOrientationMaskAll;
}
return _supportedInterfaceOrientations;
}
#endif
@end