hideToast
Overview
hideToast:options: hides the Toast message that is currently being displayed.
Normally, a Toast disappears automatically after the configured duration elapses. When the business needs to dismiss the Toast early—for example, closing a loading Toast, switching pages, or when a task ends—you can call this interface to hide it proactively.
Type Declaration
objectivec
@interface SUDOPHideToastOptions : NSObject
@property(nonatomic, assign) BOOL noConflict;
@endMethod Declaration
objectivec
/**
Hides the currently displayed toast message.
@param stateHandle The state handle object that manages the operation state and callbacks.
@param options The options configuration for hiding the toast.
*/
- (void)hideToast:(id<SUDOPStateHandle>)stateHandle
options:(SUDOPHideToastOptions *)options;Parameters
SUDOPHideToastOptions
| Parameter | Type | Required | Description |
|---|---|---|---|
noConflict | BOOL | No | Whether to enable the non-conflicting hide strategy. The actual behavior depends on the SDK implementation, and is typically used to avoid hiding a Toast being displayed by another business or another caller. |
Method Parameters
| Parameter | Type | Required | Description | | --- | --- | --- | | stateHandle | id<SUDOPStateHandle> | Yes | The state handle object, used to manage the current operation state and callbacks. | | options | SUDOPHideToastOptions * | Yes | The configuration object for hiding the Toast. |
Example
Hide the Toast proactively
objectivec
id<SUDOPStateHandle> stateHandle = self.stateHandle;
SUDOPHideToastOptions *options = [[SUDOPHideToastOptions alloc] init];
options.noConflict = YES;
[self hideToast:stateHandle options:options];Use together with a loading Toast
objectivec
// Show a loading Toast
SUDOPShowToastOptions *showOptions = [[SUDOPShowToastOptions alloc] init];
showOptions.title = @"Loading";
showOptions.icon = kSUDOPShowToastOptionsIconTypeLoading;
showOptions.duration = 10000;
showOptions.mask = YES;
[self showToast:self.stateHandle options:showOptions];
// Hide the Toast after the asynchronous task completes
SUDOPHideToastOptions *hideOptions = [[SUDOPHideToastOptions alloc] init];
hideOptions.noConflict = YES;
[self hideToast:self.stateHandle options:hideOptions];Process Flow
- A Toast displayed via
showToast:options:already exists in the current page or global environment. - The business side creates a
SUDOPHideToastOptionsobject. - Set
noConflictas needed. - Call
hideToast:options:. - The SDK hides the Toast that is currently being displayed.
- The execution result or exception information is returned via the state callback.
Notes
hideToast:options:can be used to dismiss a Toast displayed viashowToast:options:early.- If the Toast has already disappeared automatically, calling this method again may not produce any visible effect.
stateHandleshould not be empty; otherwise the SDK may fail to correctly manage the current operation state or callbacks.optionsshould not be empty.- The exact semantics of
noConflictdepend on the actual SDK implementation; if the SDK supports multi-Toast scenarios, this field may be used to avoid mistakenly hiding a Toast in another calling context. - For a Toast with
icon = loadingor a longduration, it is recommended to proactively callhideToast:options:after the task ends. - This method has no synchronous return value; the hide result or exception information should be based on the SDK callback or state callback.
