UIKit.UIActionSheet Class
A UIKit.UIView that displays an action sheet with one or more buttons. (As of iOS 8, devs should use UIKit.UIAlertController rather than this class.)

See Also: UIActionSheet Members


[Foundation.Register("UIActionSheet", true)]
public class UIActionSheet : UIView, IEnumerable

See Also



As of iOS 8, app devs should use UIKit.UIAlertController rather than this class. Extensions may not use this class at all.

The UIKit.UIActionSheet control is a convenient way to allow the application user to choose among alternative actions. The following code and diagram are taken from the "Action Sheets" section of the "iOS Standard Controls" sample.

C# Example

protected void HandleBtnActionSheetWithOtherButtonsTouchUpInside (object sender, EventArgs e)
	actionSheet = new UIActionSheet ("action sheet with other buttons");
	actionSheet.AddButton ("delete");
	actionSheet.AddButton ("cancel");
	actionSheet.AddButton ("a different option!");
	actionSheet.AddButton ("another option");
	actionSheet.DestructiveButtonIndex = 0;
	actionSheet.CancelButtonIndex = 1;
	//actionSheet.FirstOtherButtonIndex = 2;
	actionSheet.Clicked += delegate(object a, UIButtonEventArgs b) {
		Console.WriteLine ("Button " + b.ButtonIndex.ToString () + " clicked");
	actionSheet.ShowInView (View);

The MonoTouch API supports two styles of event notification: the Objective-C style that uses a delegate class or the C# style using event notifications.

The C# style allows the user to add or remove event handlers at runtime by assigning to the events of properties of this class. Event handlers can be anyone of a method, an anonymous methods or a lambda expression. Using the C# style events or properties will override any manual settings to the Objective-C Delegate or WeakDelegate settings.

The Objective-C style requires the user to create a new class derived from UIKit.UIActionSheetDelegate class and assign it to the UIKit.Delegate property. Alternatively, for low-level control, by creating a class derived from Foundation.NSObject which has every entry point properly decorated with an [Export] attribute. The instance of this object can then be assigned to the UIActionSheet.WeakDelegate property.

Related content


Namespace: UIKit
Assembly: Xamarin.iOS (in Xamarin.iOS.dll)
Assembly Versions: