diff options
Diffstat (limited to 'Xamarin.Forms.Platform.iOS/Platform.cs')
-rw-r--r-- | Xamarin.Forms.Platform.iOS/Platform.cs | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/Xamarin.Forms.Platform.iOS/Platform.cs b/Xamarin.Forms.Platform.iOS/Platform.cs index 805aba7d..c9c31887 100644 --- a/Xamarin.Forms.Platform.iOS/Platform.cs +++ b/Xamarin.Forms.Platform.iOS/Platform.cs @@ -46,7 +46,14 @@ namespace Xamarin.Forms.Platform.iOS if (!PageIsChildOfPlatform(sender)) return; - PresentAlert(arguments); + if (Forms.IsiOS8OrNewer) + { + PresentAlert(arguments); + } + else + { + PresentPre8Alert(arguments); + } }); MessagingCenter.Subscribe(this, Page.ActionSheetSignalName, (Page sender, ActionSheetArguments arguments) => @@ -57,8 +64,16 @@ namespace Xamarin.Forms.Platform.iOS var pageRoot = sender; while (!Application.IsApplicationOrNull(pageRoot.RealParent)) pageRoot = (Page)pageRoot.RealParent; + var pageRenderer = GetRenderer(pageRoot); - PresentActionSheet(arguments); + if (Forms.IsiOS8OrNewer) + { + PresentActionSheet(arguments); + } + else + { + PresentPre8ActionSheet(arguments, pageRenderer); + } }); } @@ -437,6 +452,12 @@ namespace Xamarin.Forms.Platform.iOS alert.PopoverPresentationController.PermittedArrowDirections = 0; // No arrow } + if(!Forms.IsiOS9OrNewer) + { + // For iOS 8, we need to explicitly set the size of the window + window.Frame = new RectangleF(0, 0, UIScreen.MainScreen.Bounds.Width, UIScreen.MainScreen.Bounds.Height); + } + window.RootViewController.PresentViewController(alert, true, null); } @@ -470,6 +491,18 @@ namespace Xamarin.Forms.Platform.iOS await Task.Delay(5); } + void PresentPre8Alert(AlertArguments arguments) + { + UIAlertView alertView; + if (arguments.Accept != null) + alertView = new UIAlertView(arguments.Title, arguments.Message, null, arguments.Cancel, arguments.Accept); + else + alertView = new UIAlertView(arguments.Title, arguments.Message, null, arguments.Cancel); + + alertView.Dismissed += (o, args) => arguments.SetResult(args.ButtonIndex != 0); + alertView.Show(); + } + void PresentPre8ActionSheet(ActionSheetArguments arguments, IVisualElementRenderer pageRenderer) { var actionSheet = new UIActionSheet(arguments.Title, null, arguments.Cancel, arguments.Destruction, |