---
title: "actionSheet(_:willDismissWithButtonIndex:)"
framework: uikit
role: symbol
role_heading: Instance Method
path: "uikit/uiactionsheetdelegate/actionsheet(_:willdismisswithbuttonindex:)"
---

# actionSheet(_:willDismissWithButtonIndex:)

Sent to the delegate before an action sheet is dismissed.

## Declaration

```swift
optional func actionSheet(_ actionSheet: UIActionSheet, willDismissWithButtonIndex buttonIndex: Int)
```

## Parameters

- `actionSheet`: The action sheet that is about to be dismissed.
- `buttonIndex`: The index of the button that was clicked. If this is the cancel button index, the action sheet is canceling. If -1, the cancel button index is not set.

## Discussion

Discussion This method is invoked before the animation begins and the view is hidden.

## See Also

### Customizing behavior

- [willPresent(_:)](uikit/uiactionsheetdelegate/willpresent(_:).md)
- [didPresent(_:)](uikit/uiactionsheetdelegate/didpresent(_:).md)
- [actionSheet(_:didDismissWithButtonIndex:)](uikit/uiactionsheetdelegate/actionsheet(_:diddismisswithbuttonindex:).md)
