Skip to content

showLoading ​

接口说明 ​

showLoading:options: 用于向用户展示加载提示组件,通常表现为加载中的进度 HUD。

调用方可以通过 SUDOPShowLoadingOptions 配置加载提示文案以及是否显示透明遮罩层。当设置遮罩层后,加载提示展示期间可以阻止用户点击页面背后的内容,避免重复操作或误触。

类型声明 ​

objectivec
/**
 Options for configuring loading indicator (progress HUD) display behavior.
 */
@interface SUDOPShowLoadingOptions : NSObject

/**
 Whether to show a transparent mask layer to prevent touch-through events.
 When set to YES, user interactions behind the loading indicator are blocked.
 */
@property(nonatomic, assign) BOOL mask;

/**
 The text title to be displayed alongside the loading indicator.
 (e.g., "Loading...", "Please wait...")
 */
@property(nonatomic, strong) NSString *title;

@end

方法声明 ​

objectivec
/**
 Displays a loading indicator (progress HUD) to the user.
 @param stateHandle The state handle object that manages the operation state and callbacks.
 @param options The options configuration for the loading indicator (e.g., text, style, mask type).
 */
- (void)showLoading:(id<SUDOPStateHandle>)stateHandle
            options:(SUDOPShowLoadingOptions *)options;

参数说明 ​

SUDOPShowLoadingOptions ​

参数类型是否必填说明
maskBOOL否是否显示透明遮罩层。设置为 YES 时,加载提示展示期间会阻止用户点击背后的页面内容。
titleNSString *否加载提示文案,例如 Loading...、请稍候...。

方法参数 ​

参数类型是否必填说明
stateHandleid<SUDOPStateHandle>是状态句柄对象,用于管理当前操作状态及回调。
optionsSUDOPShowLoadingOptions *是加载提示配置对象,包含提示文案、遮罩层等配置。

使用示例 ​

objectivec
id<SUDOPStateHandle> stateHandle = self.stateHandle;

SUDOPShowLoadingOptions *options = [[SUDOPShowLoadingOptions alloc] init];
options.mask = YES;
options.title = @"加载中...";

[self showLoading:stateHandle options:options];

处理流程 ​

  1. 业务侧创建 SUDOPShowLoadingOptions 对象。
  2. 根据业务需求设置加载提示文案 title。
  3. 根据业务需求设置是否展示透明遮罩层 mask。
  4. 调用 showLoading:options: 展示加载提示。
  5. SDK 在当前页面或指定容器上展示加载提示组件。
  6. 加载完成后,业务侧应调用对应的隐藏加载提示接口关闭 loading。

注意事项 ​

  • stateHandle 不应为空,否则 SDK 可能无法正确管理当前操作状态或回调。
  • options 不应为空。
  • title 可以为空;为空时 SDK 可能仅展示加载动画,具体表现以 SDK 实现为准。
  • mask 设置为 YES 时,可以避免加载过程中用户继续点击页面内容。
  • mask 设置为 NO 时,加载提示背后的页面可能仍可响应用户交互。
  • showLoading:options: 通常需要与隐藏 loading 的接口配合使用,避免 loading 长时间停留在页面上。
  • 如果短时间内多次调用该方法,SDK 可能会更新已有 loading,也可能叠加展示,具体行为以 SDK 实现为准。
  • 该方法无同步返回值,展示状态或异常结果应以 SDK 回调或状态回调为准。