<!--
{
  "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/UIAlertViewDelegate/alertView(_:didDismissWithButtonIndex:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(pl)UIAlertViewDelegate(im)alertView:didDismissWithButtonIndex:"
  },
  "title" : "alertView(_:didDismissWithButtonIndex:)"
}
-->

# alertView(_:didDismissWithButtonIndex:)

Sent to the delegate after an alert view is dismissed from the screen.

```
optional func alertView(_ alertView: UIAlertView, didDismissWithButtonIndex buttonIndex: Int)
```

## Parameters

`alertView`

The alert view that was dismissed.

`buttonIndex`

The index of the button that was clicked. The button indices start at `0`. If this is the cancel button index, the alert view is canceling. If `-1`, the cancel button index is not set.

## Discussion

This method is invoked after the animation ends and the view is hidden.

---

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)