Skip to content

Commit 68c930f

Browse files
committed
macOS does not use PopoverPresentationController
Fixes #18156
1 parent 7773f90 commit 68c930f

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/Controls/src/Core/Platform/AlertManager/AlertManager.iOS.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,11 +177,14 @@ void PresentActionSheet(Page sender, ActionSheetArguments arguments)
177177

178178
static void PresentPopUp(Page sender, Window virtualView, UIWindow platformView, UIAlertController alert, ActionSheetArguments arguments = null)
179179
{
180-
if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad && arguments != null)
180+
if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad &&
181+
arguments is not null &&
182+
alert.PopoverPresentationController is not null &&
183+
platformView.RootViewController?.View is not null)
181184
{
182185
UIDevice.CurrentDevice.BeginGeneratingDeviceOrientationNotifications();
183186
var observer = NSNotificationCenter.DefaultCenter.AddObserver(UIDevice.OrientationDidChangeNotification,
184-
n => { alert.PopoverPresentationController.SourceRect = platformView.RootViewController.View.Bounds; });
187+
n => alert.PopoverPresentationController.SourceRect = platformView.RootViewController.View.Bounds);
185188

186189
arguments.Result.Task.ContinueWith(t =>
187190
{
@@ -214,7 +217,7 @@ static void PresentPopUp(Page sender, Window virtualView, UIWindow platformView,
214217
static UIViewController GetTopUIViewController(UIWindow platformWindow)
215218
{
216219
var topUIViewController = platformWindow.RootViewController;
217-
while (topUIViewController.PresentedViewController is not null)
220+
while (topUIViewController?.PresentedViewController is not null)
218221
{
219222
topUIViewController = topUIViewController.PresentedViewController;
220223
}

0 commit comments

Comments
 (0)