diff --git a/src/Compatibility/Core/src/iOS/ContextActionCell.cs b/src/Compatibility/Core/src/iOS/ContextActionCell.cs index e91587cd126b..784d79427244 100644 --- a/src/Compatibility/Core/src/iOS/ContextActionCell.cs +++ b/src/Compatibility/Core/src/iOS/ContextActionCell.cs @@ -345,15 +345,18 @@ void ActivateMore() if (controller == null) throw new InvalidOperationException("No UIViewController found to present."); - if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone) + if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone || (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad && actionSheet.PopoverPresentationController == null)) { var cancel = UIAlertAction.Create(StringResources.Cancel, UIAlertActionStyle.Cancel, null); actionSheet.AddAction(cancel); } else { - actionSheet.PopoverPresentationController.SourceView = _tableView; - actionSheet.PopoverPresentationController.SourceRect = sourceRect; + if (actionSheet.PopoverPresentationController != null) + { + actionSheet.PopoverPresentationController.SourceView = _tableView; + actionSheet.PopoverPresentationController.SourceRect = sourceRect; + } } controller.PresentViewController(actionSheet, true, null); diff --git a/src/Compatibility/Core/src/iOS/Platform.cs b/src/Compatibility/Core/src/iOS/Platform.cs index 37ccdfe94be4..d1503c2929c2 100644 --- a/src/Compatibility/Core/src/iOS/Platform.cs +++ b/src/Compatibility/Core/src/iOS/Platform.cs @@ -518,7 +518,11 @@ static void PresentPopUp(UIWindow window, UIAlertController alert, ActionSheetAr { UIDevice.CurrentDevice.BeginGeneratingDeviceOrientationNotifications(); var observer = NSNotificationCenter.DefaultCenter.AddObserver(UIDevice.OrientationDidChangeNotification, - n => { alert.PopoverPresentationController.SourceRect = window.RootViewController.View.Bounds; }); + n => + { + if (alert.PopoverPresentationController != null) + alert.PopoverPresentationController.SourceRect = window.RootViewController.View.Bounds; + }); arguments.Result.Task.ContinueWith(t => { @@ -526,9 +530,12 @@ static void PresentPopUp(UIWindow window, UIAlertController alert, ActionSheetAr UIDevice.CurrentDevice.EndGeneratingDeviceOrientationNotifications(); }, TaskScheduler.FromCurrentSynchronizationContext()); - alert.PopoverPresentationController.SourceView = window.RootViewController.View; - alert.PopoverPresentationController.SourceRect = window.RootViewController.View.Bounds; - alert.PopoverPresentationController.PermittedArrowDirections = 0; // No arrow + if (alert.PopoverPresentationController != null) + { + alert.PopoverPresentationController.SourceView = window.RootViewController.View; + alert.PopoverPresentationController.SourceRect = window.RootViewController.View.Bounds; + alert.PopoverPresentationController.PermittedArrowDirections = 0; // No arrow + } } window.RootViewController.PresentViewController(alert, true, null); diff --git a/src/Controls/src/Core/Compatibility/Handlers/ListView/iOS/ContextActionCell.cs b/src/Controls/src/Core/Compatibility/Handlers/ListView/iOS/ContextActionCell.cs index 47c16b8d96b4..589788cd4bfb 100644 --- a/src/Controls/src/Core/Compatibility/Handlers/ListView/iOS/ContextActionCell.cs +++ b/src/Controls/src/Core/Compatibility/Handlers/ListView/iOS/ContextActionCell.cs @@ -340,15 +340,18 @@ void ActivateMore() if (controller == null) throw new InvalidOperationException("No UIViewController found to present."); - if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone) + if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone || (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad && actionSheet.PopoverPresentationController == null)) { var cancel = UIAlertAction.Create(StringResources.Cancel, UIAlertActionStyle.Cancel, null); actionSheet.AddAction(cancel); } else { - actionSheet.PopoverPresentationController.SourceView = _tableView; - actionSheet.PopoverPresentationController.SourceRect = sourceRect; + if (actionSheet.PopoverPresentationController != null) + { + actionSheet.PopoverPresentationController.SourceView = _tableView; + actionSheet.PopoverPresentationController.SourceRect = sourceRect; + } } controller.PresentViewController(actionSheet, true, null);