<!--
{
  "availability" : [
    "iOS: 2.0.0 - 9.0.0",
    "iPadOS: 2.0.0 - 9.0.0",
    "macCatalyst: 13.1.0 - 13.1.0"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UIAlertView",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UIAlertView"
  },
  "title" : "UIAlertView"
}
-->

# UIAlertView

A view that displays an alert message.

```
@MainActor class UIAlertView
```

## Overview

In apps that run in versions of iOS prior to iOS 8, use the [`UIAlertView`](/documentation/UIKit/UIAlertView) class to display an alert message to the user. An alert view functions similar to but differs in appearance from an action sheet (an instance of [`UIActionSheet`](/documentation/UIKit/UIActionSheet)).

### Using an alert view

Use the properties and methods defined in this class to set the title, message, and delegate of an alert view and configure the buttons in apps that run in versions of iOS prior to iOS 8. You must set a delegate if you add custom buttons. The delegate should conform to the [`UIAlertViewDelegate`](/documentation/UIKit/UIAlertViewDelegate) protocol. Use the [`show()`](/documentation/UIKit/UIAlertView/show()) method to display an alert view after it’s configured.

### Subclassing notes

The [`UIAlertView`](/documentation/UIKit/UIAlertView) class is intended to be used as-is and doesn’t support subclassing. The view hierarchy for this class is private and must not be modified.

## Topics

### Creating alert views

[`-  initWithTitle:message:delegate:cancelButtonTitle:otherButtonTitles:`](/documentation/UIKit/UIAlertView/init(title:message:delegate:cancelButtonTitle:))

Convenience method for initializing an alert view.

[`init(title:message:delegate:cancelButtonTitle:otherButtonTitles:_:)`](/documentation/UIKit/UIAlertView/init(title:message:delegate:cancelButtonTitle:otherButtonTitles:_:))

Creates an alert view with the specified values.

[`-  initWithFrame:`](/documentation/UIKit/UIAlertView/init(frame:))

Creates an alert view with the specified frame.

[`-  initWithCoder:`](/documentation/UIKit/UIAlertView/init(coder:))

Creates an alert view from data in an unarchiver.

### Setting properties

[`delegate`](/documentation/UIKit/UIAlertView/delegate)

The receiver’s delegate or `nil` if it doesn’t have a delegate.

[`alertViewStyle`](/documentation/UIKit/UIAlertView/alertViewStyle)

The kind of alert displayed to the user.

[`title`](/documentation/UIKit/UIAlertView/title)

The string that appears in the receiver’s title bar.

[`message`](/documentation/UIKit/UIAlertView/message)

Descriptive text that provides more details than the title.

[`visible`](/documentation/UIKit/UIAlertView/isVisible)

A Boolean value that indicates whether the receiver is displayed.

### Configuring buttons

[`-  addButtonWithTitle:`](/documentation/UIKit/UIAlertView/addButton(withTitle:))

Adds a button to the receiver with the given title.

[`numberOfButtons`](/documentation/UIKit/UIAlertView/numberOfButtons)

The number of buttons on the alert view.

[`-  buttonTitleAtIndex:`](/documentation/UIKit/UIAlertView/buttonTitle(at:))

Returns the title of the button at the given index.

[`-  textFieldAtIndex:`](/documentation/UIKit/UIAlertView/textField(at:))

Returns the text field at the given index

[`cancelButtonIndex`](/documentation/UIKit/UIAlertView/cancelButtonIndex)

The index number of the cancel button.

[`firstOtherButtonIndex`](/documentation/UIKit/UIAlertView/firstOtherButtonIndex)

The index of the first other button.

### Displaying

[`-  show`](/documentation/UIKit/UIAlertView/show())

Displays the receiver using animation.

### Dismissing

[`-  dismissWithClickedButtonIndex:animated:`](/documentation/UIKit/UIAlertView/dismiss(withClickedButtonIndex:animated:))

Dismisses the receiver, optionally with animation.

### Constants

[`UIAlertViewStyle`](/documentation/UIKit/UIAlertViewStyle)

The presentation style of the alert.

## Relationships

### Conforms To

[`Hashable`](/documentation/Swift/Hashable)

[`CMBodyIdentifiable`](/documentation/CoreMotion/CMBodyIdentifiable)

[`UIAppearance`](/documentation/UIKit/UIAppearance)

[`UIPasteConfigurationSupporting`](/documentation/UIKit/UIPasteConfigurationSupporting)

[`UIActivityItemsConfigurationProviding`](/documentation/UIKit/UIActivityItemsConfigurationProviding)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`UITraitEnvironment`](/documentation/UIKit/UITraitEnvironment)

[`CALayerDelegate`](/documentation/QuartzCore/CALayerDelegate)

[`UIAccessibilityIdentification`](/documentation/UIKit/UIAccessibilityIdentification)

[`NSCoding`](/documentation/Foundation/NSCoding)

[`UIFocusItem`](/documentation/UIKit/UIFocusItem)

[`CLBodyIdentifiable`](/documentation/CoreLocation/CLBodyIdentifiable)

[`UICoordinateSpace`](/documentation/UIKit/UICoordinateSpace)

[`UIAppearanceContainer`](/documentation/UIKit/UIAppearanceContainer)

[`Sendable`](/documentation/Swift/Sendable)

[`UIFocusEnvironment`](/documentation/UIKit/UIFocusEnvironment)

[`UILargeContentViewerItem`](/documentation/UIKit/UILargeContentViewerItem)

[`UITraitChangeObservable-67e94`](/documentation/UIKit/UITraitChangeObservable-67e94)

[`UIDynamicItem`](/documentation/UIKit/UIDynamicItem)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`UIResponderStandardEditActions`](/documentation/UIKit/UIResponderStandardEditActions)

[`CVarArg`](/documentation/Swift/CVarArg)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`UIPopoverPresentationControllerSourceItem`](/documentation/UIKit/UIPopoverPresentationControllerSourceItem)

[`UIUserActivityRestoring`](/documentation/UIKit/UIUserActivityRestoring)

[`Equatable`](/documentation/Swift/Equatable)

[`NSTouchBarProvider`](/documentation/AppKit/NSTouchBarProvider)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`UIFocusItemContainer`](/documentation/UIKit/UIFocusItemContainer)

### Inherits From

[`UIView`](/documentation/UIKit/UIView)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)