Skip to content

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;

@end

Method 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 ​

ParameterTypeRequiredDescription
alertTextNSString *NoThe 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".
itemListNSArray<NSString *> *YesThe list of operation button titles; the maximum array length is 6.
itemColorNSString *NoThe text color of the operation buttons, e.g., #FF0000.

Method Parameters ​

ParameterTypeRequiredDescription
stateHandleid<SUDOPStateHandle>YesThe state handle object, used to manage the current operation state and callbacks.
optionsSUDOPShowActionSheetOptions *YesThe 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 ​

  1. The business side creates a SUDOPShowActionSheetOptions object.
  2. Set the operation item list itemList.
  3. Set the top prompt text alertText as needed.
  4. Set the button text color itemColor as needed.
  5. Call showActionSheet:options: to display the action sheet.
  6. The user taps an operation item or dismisses the sheet.
  7. 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 ​

  • stateHandle should not be empty; otherwise the SDK may fail to correctly manage the current operation state or callbacks.
  • options should not be empty.
  • itemList is recommended to be required and to contain at least one operation item.
  • The maximum length of itemList is 6; when the limit is exceeded, the SDK may truncate, report an error, or display abnormally, depending on the SDK implementation.
  • Each item in itemList is recommended to be a non-empty string.
  • alertText is an optional field; when it is not set, the top of the action sheet may not display prompt text.
  • itemColor is recommended to use a valid color string, e.g., #FF0000 or #333333.
  • To highlight a dangerous operation such as "Delete", you can set itemColor to red.
  • The result after the user taps a specific operation item is typically obtained via the stateHandle related 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.