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

# cancelButtonIndex

The index number of the cancel button.

```
var cancelButtonIndex: Int { get set }
```

## Discussion

Button indices start at `0`. The default value of this property is normally `-1`, which indicates that no cancel button has been set. However, a cancel button may be created and set automatically by the [`init(title:delegate:cancelButtonTitle:destructiveButtonTitle:)`](/documentation/UIKit/UIActionSheet/init(title:delegate:cancelButtonTitle:destructiveButtonTitle:)) method. If you use that method to create a cancel button, you should not change the value of this property.

When presenting an action sheet on an iPad, there are times when you should not include a cancel button. For more information on when you should include a cancel button, see the class overview or [iOS Human Interface Guidelines](https://developer.apple.com/ios/human-interface-guidelines/).

---

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)