Exemplo n.º 1
0
        private static async Task <int?> ShowInternal(object uiViewObject, string title, UIActionSheetStyle style, params string[] options)
        {
            var signal          = new ManualResetEventSlim();
            int?retval          = null;
            var alertController = UIAlertController.Create(title ?? string.Empty, string.Empty, UIAlertControllerStyle.ActionSheet);

            if (uiViewObject != null)
            {
                alertController.PopoverPresentationController?.SetPresentationAnchor(uiViewObject);
            }

            for (int i = 0; i < options.Length; i++)
            {
                var option = options[i];
                var index  = i;
                alertController.AddAction(
                    UIAlertAction.Create(option, UIAlertActionStyle.Default,
                                         (x) => {
                    retval = index;
                    signal.Set();
                }
                                         )
                    );
            }
            alertController.AddAction(
                UIAlertAction.Create(
                    "Cancel",
                    UIAlertActionStyle.Cancel,
                    (x) => {
                retval = null;
                signal.Set();
            }
                    )
                );

            Tools.iOSTool.GetTopMostController().PresentViewController(alertController, true, null);
            await Task.Run(() => signal.Wait());

            return(retval);
        }
Exemplo n.º 2
0
 public static Task <int?> Show(object userInterfaceObject, string title, UIActionSheetStyle style, params string[] options)
 {
     return(ShowInternal(userInterfaceObject, title, style, options));
 }
Exemplo n.º 3
0
 public static Task <int?> ShowFromButtonItem(UIBarButtonItem item, bool animated, string title, UIActionSheetStyle style, params string[] options)
 {
     return(ShowInternal(item, title, style, options));
 }
Exemplo n.º 4
0
 public static Task <int?> ShowFromToolbar(UIToolbar toolbar, string title, UIActionSheetStyle style, params string[] options)
 {
     return(ShowInternal(toolbar, title, style, options));
 }
Exemplo n.º 5
0
 public static Task <int?> ShowInCell(UIView view, string title, UIActionSheetStyle style, params string[] options)
 {
     return(ShowInternal(view, title, style, options));
 }