From 13fd2015e5b857e735c462c96e8e358ad9750304 Mon Sep 17 00:00:00 2001 From: Kyle Matthew Hedden Date: Wed, 9 Nov 2022 21:12:58 -0500 Subject: [PATCH] prevent crashes when ipads attempt to show an actionsheet without a source rect --- MVMCoreUI/Alerts/MVMCoreAlertHandler.m | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/MVMCoreUI/Alerts/MVMCoreAlertHandler.m b/MVMCoreUI/Alerts/MVMCoreAlertHandler.m index 75dab8f1..16fb1f4a 100644 --- a/MVMCoreUI/Alerts/MVMCoreAlertHandler.m +++ b/MVMCoreUI/Alerts/MVMCoreAlertHandler.m @@ -83,6 +83,11 @@ [self removeAllAlertViews]; } + if (alertStyle == UIAlertControllerStyleActionSheet && UIDevice.currentDevice.userInterfaceIdiom != UIUserInterfaceIdiomPhone) { + // ActionSheets are not supported on iPad interfaces without a source rect (i.e. a source element) which isn't currently supported for our generic handling. + alertStyle = UIAlertControllerStyleAlert; + } + // Create the alert. Adds the actions one by one. MVMCoreAlertController *alertController = [MVMCoreAlertController alertControllerWithTitle:(title ?: @"") message:message preferredStyle:alertStyle]; for (NSUInteger i = 0; i < [actions count]; i++) {