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

See Also: UIAlertView Members

Syntax

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

Remarks

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

The MonoTouch.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.AddButton("OK");
alert.Show ();
        

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

The application developer can use MonoTouch.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 MonoTouch.UIKit.UIAlertViewDelegate class and assign it to the MonoTouch.UIKit.Delegate property. Alternatively, for low-level control, by creating a class derived from MonoTouch.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

Requirements

Namespace: MonoTouch.UIKit
Assembly: monotouch (in monotouch.dll)
Assembly Versions: 0.0.0.0