From fd554c31c7bcb2aae5c7d6a64e5bef9bedf56ebb Mon Sep 17 00:00:00 2001 From: Alex Kotliarskyi Date: Mon, 10 Oct 2016 12:01:52 -0700 Subject: [PATCH] Fix devmenu on iPad Summary: This fixes the following problem on iPad (happens when trying to show the devmenu ActionSheet): > Terminating app due to uncaught exception 'NSGenericException', reason: 'Your application has presented a UIAlertController () of style UIAlertControllerStyleActionSheet. The modalPresentationStyle of a UIAlertController with this style is UIModalPresentationPopover. You must provide location information for this popover through the alert controller's popoverPresentationController. You must provide either a sourceView and sourceRect or a barButtonItem. If this information is not known when you present the alert controller, you may provide it in the UIPopoverPresentationControllerDelegate method -prepareForPopoverPresentation.' I see 2 ways of fixing the issue: falling back to Alert (always displayed in the center) or adding a fake view somewhere on the screen to display the ActionSheet. Reviewed By: mmmulani Differential Revision: D3989672 fbshipit-source-id: 59fabc50ec1aac3ae6ddd7ecf4d8e8e5b9586dba --- React/Modules/RCTDevMenu.m | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/React/Modules/RCTDevMenu.m b/React/Modules/RCTDevMenu.m index 648e53333..f0fc6a296 100644 --- a/React/Modules/RCTDevMenu.m +++ b/React/Modules/RCTDevMenu.m @@ -513,9 +513,12 @@ RCT_EXPORT_METHOD(show) } NSString *title = [NSString stringWithFormat:@"React Native: Development (%@)", [_bridge class]]; + // On larger devices we don't have an anchor point for the action sheet + UIAlertControllerStyle style = [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone ? UIAlertControllerStyleActionSheet : UIAlertControllerStyleAlert; _actionSheet = [UIAlertController alertControllerWithTitle:title message:@"" - preferredStyle:UIAlertControllerStyleActionSheet]; + preferredStyle:style]; + NSArray *items = [self menuItems]; for (RCTDevMenuItem *item in items) { switch (item.type) {