Skip to content

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;

@end

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

ParameterTypeRequiredDescription
noConflictBOOLNoWhether 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 ​

  1. A Toast displayed via showToast:options: already exists in the current page or global environment.
  2. The business side creates a SUDOPHideToastOptions object.
  3. Set noConflict as needed.
  4. Call hideToast:options:.
  5. The SDK hides the Toast that is currently being displayed.
  6. The execution result or exception information is returned via the state callback.

Notes ​

  • hideToast:options: can be used to dismiss a Toast displayed via showToast:options: early.
  • If the Toast has already disappeared automatically, calling this method again may not produce any visible effect.
  • stateHandle should not be empty; otherwise the SDK may fail to correctly manage the current operation state or callbacks.
  • options should not be empty.
  • The exact semantics of noConflict depend 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 = loading or a long duration, it is recommended to proactively call hideToast: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.