showActionSheet
Overview
showActionSheet:options: pops up an action sheet from the bottom, presenting a set of selectable operations to the user.
It is commonly used to let the user choose among multiple operations, such as "Take Photo / Choose from Album" or "Edit / Delete / Cancel".
Type Declaration
objectivec
/**
Options for configuring action sheet display behavior.
*/
@interface SUDOPShowActionSheetOptions : NSObject
/**
The warning or alert text displayed at the top of the action sheet.
(e.g., "Are you sure?", "This action cannot be undone.")
*/
@property(nonatomic, strong) NSString *alertText;
/**
The list of button titles to be displayed in the action sheet.
The maximum length of the array is 6.
*/
@property(nonatomic, strong) NSArray<NSString *> *itemList;
/**
The text color of the buttons (e.g., "#FF0000").
*/
@property(nonatomic, strong) NSString *itemColor;
@endMethod Declaration
objectivec
/**
Displays an action sheet (bottom sheet) with a list of selectable options.
@param stateHandle The state handle object that manages the operation state and callbacks.
@param options The options configuration for the action sheet (alert text, item list, item color, etc.).
*/
- (void)showActionSheet:(id<SUDOPStateHandle>)stateHandle
options:(SUDOPShowActionSheetOptions *)options;Parameters
SUDOPShowActionSheetOptions
| Parameter | Type | Required | Description |
|---|---|---|---|
alertText | NSString * | No | The prompt or warning text at the top of the action sheet, e.g., "Are you sure you want to delete?" or "This action cannot be undone". |
itemList | NSArray<NSString *> * | Yes | The list of operation button titles; the maximum array length is 6. |
itemColor | NSString * | No | The text color of the operation buttons, e.g., #FF0000. |
Method Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
stateHandle | id<SUDOPStateHandle> | Yes | The state handle object, used to manage the current operation state and callbacks. |
options | SUDOPShowActionSheetOptions * | Yes | The action sheet display configuration object, containing the top prompt text, operation item list, button color, and other settings. |
Example
Display a basic Action Sheet
objectivec
id<SUDOPStateHandle> stateHandle = self.stateHandle;
SUDOPShowActionSheetOptions *options = [[SUDOPShowActionSheetOptions alloc] init];
options.itemList = @[@"Take Photo", @"Choose from Album"];
[self showActionSheet:stateHandle options:options];Display an Action Sheet with prompt text
objectivec
SUDOPShowActionSheetOptions *options = [[SUDOPShowActionSheetOptions alloc] init];
options.alertText = @"Please select an image source";
options.itemList = @[@"Take Photo", @"Choose from Album"];
[self showActionSheet:self.stateHandle options:options];Set button text color
objectivec
SUDOPShowActionSheetOptions *options = [[SUDOPShowActionSheetOptions alloc] init];
options.alertText = @"This cannot be recovered after deletion";
options.itemList = @[@"Delete"];
options.itemColor = @"#FF0000";
[self showActionSheet:self.stateHandle options:options];Multiple operation items example
objectivec
SUDOPShowActionSheetOptions *options = [[SUDOPShowActionSheetOptions alloc] init];
options.alertText = @"Please select an operation";
options.itemList = @[@"Edit", @"Share", @"Favorite", @"Delete"];
options.itemColor = @"#333333";
[self showActionSheet:self.stateHandle options:options];Process Flow
- The business side creates a
SUDOPShowActionSheetOptionsobject. - Set the operation item list
itemList. - Set the top prompt text
alertTextas needed. - Set the button text color
itemColoras needed. - Call
showActionSheet:options:to display the action sheet. - The user taps an operation item or dismisses the sheet.
- The SDK returns the user's selection result or cancellation result via the state callback; the actual callback data structure depends on the SDK implementation.
Notes
stateHandleshould not be empty; otherwise the SDK may fail to correctly manage the current operation state or callbacks.optionsshould not be empty.itemListis recommended to be required and to contain at least one operation item.- The maximum length of
itemListis6; when the limit is exceeded, the SDK may truncate, report an error, or display abnormally, depending on the SDK implementation. - Each item in
itemListis recommended to be a non-empty string. alertTextis an optional field; when it is not set, the top of the action sheet may not display prompt text.itemColoris recommended to use a valid color string, e.g.,#FF0000or#333333.- To highlight a dangerous operation such as "Delete", you can set
itemColorto red. - The result after the user taps a specific operation item is typically obtained via the
stateHandlerelated callbacks. - This method has no synchronous return value; the display result, selection result, or exception information should be based on the SDK callback or state callback.
