UIKit.UIAlertView Class
A UIKit.UIView that displays a dialog message with one or more buttons. (As of iOS 8, devs should use UIKit.UIAlertController rather than this class.)

See Also: UIAlertView Members


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


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

The UIKit.UIAlertView allows the application user to choose among alternative actions. The following code and image, taken from the "AlertViews" section of the "ios Standard Controls" sample illustrates the simplest use-case:

C# Example

UIAlertView alert = new UIAlertView () { 
	Title = "alert title", Message = "this is a simple alert"
alert.Show ();

An alternative to the UIKit.UIAlertView is the UIKit.UIActionSheet.

The application developer can use UIKit.UIAlertViewStyles such as UIAlertViewStyle.PlainTextInput or UIAlertViewStyle.LongAndPasswordInput to allow the application user to enter values.

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.UIAlertViewDelegate 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 UIAlertView.WeakDelegate property.

Note to Inheritors

This class should not be subclassed.

Related content


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