summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.iOS
diff options
context:
space:
mode:
authorE.Z. Hart <hartez@users.noreply.github.com>2016-11-22 17:01:20 (GMT)
committerRui Marinho <me@ruimarinho.net>2016-11-22 17:01:20 (GMT)
commit5642dd58cda563ec6328495567a5505e24e392f3 (patch)
tree83bb9f9a481b9a8375357b205688ef539b6bc8a7 /Xamarin.Forms.Platform.iOS
parent9d831bbac2e6ccca369342823f50113802067ec4 (diff)
downloadxamarin-forms-5642dd58cda563ec6328495567a5505e24e392f3.zip
xamarin-forms-5642dd58cda563ec6328495567a5505e24e392f3.tar.gz
xamarin-forms-5642dd58cda563ec6328495567a5505e24e392f3.tar.bz2
Fix broken alerts for iPad (#549)beta-2.3.4-pre1
* Fix broken alerts for iPad * Remove unnecessary parameter and add null check * Dropping test limit to 10 so we can get iOS passing
Diffstat (limited to 'Xamarin.Forms.Platform.iOS')
-rw-r--r--Xamarin.Forms.Platform.iOS/Platform.cs31
1 files changed, 16 insertions, 15 deletions
diff --git a/Xamarin.Forms.Platform.iOS/Platform.cs b/Xamarin.Forms.Platform.iOS/Platform.cs
index f39856b..189faa7 100644
--- a/Xamarin.Forms.Platform.iOS/Platform.cs
+++ b/Xamarin.Forms.Platform.iOS/Platform.cs
@@ -75,7 +75,7 @@ namespace Xamarin.Forms.Platform.iOS
if (Forms.IsiOS8OrNewer)
{
- PresentAlert(arguments, pageRenderer);
+ PresentAlert(arguments);
}
else
{
@@ -419,7 +419,7 @@ namespace Xamarin.Forms.Platform.iOS
PresentAlert(window, alert);
}
- void PresentAlert(ActionSheetArguments arguments, IVisualElementRenderer pageRenderer)
+ void PresentAlert(ActionSheetArguments arguments)
{
var alert = UIAlertController.Create(arguments.Title, null, UIAlertControllerStyle.ActionSheet);
var window = new UIWindow { BackgroundColor = Color.Transparent.ToUIColor() };
@@ -444,11 +444,21 @@ namespace Xamarin.Forms.Platform.iOS
alert.AddAction(CreateActionWithWindowHide(blabel, UIAlertActionStyle.Default, () => arguments.SetResult(blabel), window));
}
- if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad)
+ PresentAlert(window, alert, arguments);
+ }
+
+ static void PresentAlert(UIWindow window, UIAlertController alert, ActionSheetArguments arguments = null)
+ {
+ window.RootViewController = new UIViewController();
+ window.RootViewController.View.BackgroundColor = Color.Transparent.ToUIColor();
+ window.WindowLevel = UIWindowLevel.Alert + 1;
+ window.MakeKeyAndVisible();
+
+ if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad && arguments != null)
{
UIDevice.CurrentDevice.BeginGeneratingDeviceOrientationNotifications();
var observer = NSNotificationCenter.DefaultCenter.AddObserver(UIDevice.OrientationDidChangeNotification,
- n => { alert.PopoverPresentationController.SourceRect = pageRenderer.ViewController.View.Bounds; });
+ n => { alert.PopoverPresentationController.SourceRect = window.RootViewController.View.Bounds; });
arguments.Result.Task.ContinueWith(t =>
{
@@ -456,20 +466,11 @@ namespace Xamarin.Forms.Platform.iOS
UIDevice.CurrentDevice.EndGeneratingDeviceOrientationNotifications();
}, TaskScheduler.FromCurrentSynchronizationContext());
- alert.PopoverPresentationController.SourceView = pageRenderer.ViewController.View;
- alert.PopoverPresentationController.SourceRect = pageRenderer.ViewController.View.Bounds;
+ alert.PopoverPresentationController.SourceView = window.RootViewController.View;
+ alert.PopoverPresentationController.SourceRect = window.RootViewController.View.Bounds;
alert.PopoverPresentationController.PermittedArrowDirections = 0; // No arrow
}
- PresentAlert(window, alert);
- }
-
- static void PresentAlert(UIWindow window, UIAlertController alert)
- {
- window.RootViewController = new UIViewController();
- window.RootViewController.View.BackgroundColor = Color.Transparent.ToUIColor();
- window.WindowLevel = UIWindowLevel.Alert + 1;
- window.MakeKeyAndVisible();
window.RootViewController.PresentViewController(alert, true, null);
}