/// <summary>
		/// Presents a destructive alert (such as delete a file).
		/// </summary>
		/// <returns>The <c>UIAlertController</c> for the alert.</returns>
		/// <param name="title">The alert's title.</param>
		/// <param name="description">The alert's description.</param>
		/// <param name="destructiveAction">The title for the destructive action's button (such as delete).</param>
		/// <param name="controller">The View Controller that will present the alert.</param>
		/// <param name="action">The <c>AlertOKCancelDelegate</c> use to respond to the user's action.</param>
		public static UIAlertController PresentDestructiveAlert(string title, string description, string destructiveAction, UIViewController controller, AlertOKCancelDelegate action) {
			// No, inform the user that they must create a home first
			UIAlertController alert = UIAlertController.Create(title, description, UIAlertControllerStyle.Alert);

			// Add cancel button
			alert.AddAction(UIAlertAction.Create("Cancel",UIAlertActionStyle.Cancel,(actionCancel) => {
				// Any action?
				if (action!=null) {
					action(false);
				}
			}));

			// Add ok button
			alert.AddAction(UIAlertAction.Create(destructiveAction,UIAlertActionStyle.Destructive,(actionOK) => {
				// Any action?
				if (action!=null) {
					action(true);
				}
			}));

			// Display the alert
			controller.PresentViewController(alert,true,null);

			// Return created controller
			return alert;
		}
Example #2
0
        public static UIAlertController PresentOKCancelAlert(string title, string description, UIViewController controller, AlertOKCancelDelegate action)
        {
            // No, inform the user that they must create a home first
            UIAlertController alert = UIAlertController.Create(title, description, UIAlertControllerStyle.Alert);

            // Add cancel button
            alert.AddAction(UIAlertAction.Create("Cancel", UIAlertActionStyle.Cancel, (actionCancel) =>
            {
                // Any action?
                if (action != null)
                {
                    action(false);
                }
            }));

            // Add ok button
            alert.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, (actionOK) =>
            {
                // Any action?
                if (action != null)
                {
                    action(true);
                }
            }));

            // Display the alert
            controller.PresentViewController(alert, true, null);

            // Return created controller
            return(alert);
        }
Example #3
0
        public static void OKCancelDialog(UIViewController controller, string title, string msg, AlertOKCancelDelegate action = null)
        {
            var okCancelAlertController = UIAlertController.Create(title, msg, UIAlertControllerStyle.Alert);

            okCancelAlertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default,
                                                                   alert =>
            {
                if (action != null)
                {
                    action(true);
                }
            }));
            if (action != null)
            {
                okCancelAlertController.AddAction(UIAlertAction.Create("Cancel", UIAlertActionStyle.Cancel,
                                                                       alert => action(false)));
            }

            controller.PresentViewController(okCancelAlertController, true, null);
        }