sud.showActionSheet
Displays an action sheet for the user to choose one item from a list.
javascript
sud.showActionSheet(object);Parameters
| Property | Type | Required | Description |
|---|---|---|---|
| alertText | string | No | Text displayed above the options |
| itemList | Array<string> | Yes | Option labels, up to 6 items |
| itemColor | string | No | Option text color, such as #000000 |
| success | function | No | Called when the user selects an item; see the fields below |
| fail | function | No | Called when the request fails or the user cancels |
| complete | function | No | Called after success or failure, with no arguments |
Success Callback Parameters
| Property | Type | Description |
|---|---|---|
| tapIndex | number | Zero-based index of the selected item in itemList |
Failure Callback Parameters
| Property | Type | Description |
|---|---|---|
| errCode | number | Error code |
| errMsg | string | Error or cancellation description |
Usage Notes
Confirm that the target app supports this UI feature before using it. Provide a nonempty list of options. Canceling does not return a valid selection index; do not perform a selected action after cancellation.
Example
javascript
const items = ['View rules', 'Contact support'];
sud.showActionSheet({
alertText: 'Choose an action',
itemList: items,
itemColor: '#000000',
success(result) {
console.log('Selected action', items[result.tapIndex]);
},
fail(error) {
console.log('No selection made', error.errCode, error.errMsg);
}
});