Files
react-native/docs/actionsheetios.md
Héctor Ramos 9ec9567390 Flatten jsdocs to markdown plaintext
Differential Revision: D6261799

fbshipit-source-id: 269e151c5d136c1d508d9f2a060c0c670d0fe0f2
2017-11-07 16:46:52 -08:00

97 lines
2.2 KiB
Markdown

---
id: actionsheetios
title: ActionSheetIOS
layout: docs
category: APIs
permalink: docs/actionsheetios.html
next: alert
previous: accessibilityinfo
---
### Methods
- [`showActionSheetWithOptions`](docs/actionsheetios.html#showactionsheetwithoptions)
- [`showShareActionSheetWithOptions`](docs/actionsheetios.html#showshareactionsheetwithoptions)
---
# Reference
## Methods
### `showActionSheetWithOptions()`
```javascript
static showActionSheetWithOptions(options, callback)
```
Display an iOS action sheet. The `options` object must contain one or more
of:
- `options` (array of strings) - a list of button titles (required)
- `cancelButtonIndex` (int) - index of cancel button in `options`
- `destructiveButtonIndex` (int) - index of destructive button in `options`
- `title` (string) - a title to show above the action sheet
- `message` (string) - a message to show below the title
The 'callback' function takes one parameter, the zero-based index
of the selected item.
Minimal example:
```
ActionSheetIOS.showActionSheetWithOptions({
options: ['Remove', 'Cancel'],
destructiveButtonIndex: 1,
cancelButtonIndex: 0,
},
(buttonIndex) => {
if (buttonIndex === 1) { // destructive action }
});
```
---
### `showShareActionSheetWithOptions()`
```javascript
static showShareActionSheetWithOptions(options, failureCallback, successCallback)
```
Display the iOS share sheet. The `options` object should contain
one or both of `message` and `url` and can additionally have
a `subject` or `excludedActivityTypes`:
- `url` (string) - a URL to share
- `message` (string) - a message to share
- `subject` (string) - a subject for the message
- `excludedActivityTypes` (array) - the activities to exclude from the ActionSheet
NOTE: if `url` points to a local file, or is a base64-encoded
uri, the file it points to will be loaded and shared directly.
In this way, you can share images, videos, PDF files, etc.
The 'failureCallback' function takes one parameter, an error object.
The only property defined on this object is an optional `stack` property
of type `string`.
The 'successCallback' function takes two parameters:
- a boolean value signifying success or failure
- a string that, in the case of success, indicates the method of sharing