> ## Documentation Index
> Fetch the complete documentation index at: https://docs.y.uno/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Test in the sandbox first: base URL https://api-sandbox.y.uno (Test Mode in the Dashboard). Production is https://api.y.uno (Live Mode).
> Every API request needs the public-api-key and private-secret-key headers. Get them in the Dashboard at https://dashboard.y.uno/developers (Developers > Credentials); sandbox and production keys are different.
> Send an X-Idempotency-Key (a UUID) when creating payments, refunds and cancels, so retries do not create duplicates.
> Start with the Quickstart (https://docs.y.uno/docs/quickstart.md) and the agent guide (https://docs.y.uno/agents.md). To search these docs from a coding agent, connect the docs MCP server at https://docs.y.uno/mcp.

# showLoading

> 当 SDK 进入或退出加载状态时调用。

当 SDK 进入或退出加载状态时，会调用 `showLoading`。默认情况下，SDK 会显示其自身的全屏加载指示器；覆盖此控制器即可渲染您自己的加载指示器。

## 默认提供的加载指示器

在 SDK 工作期间（创建支付、3DS、加载其表单），购物者
会看到一个简单的旋转图标：

![SDK 的默认旋转图标](https://mintcdn.com/yuno-3979e326/wcaoTPfNIXrvnpRG/images/yuno-sdk/controllers/loading-spinner.gif?s=8d6fc9b446d7be5ff98dfc4d3d470b7f)

默认旋转图标，在 SDK 工作期间显示。

## 想使用您自己的加载指示器？

覆盖 `showLoading`，渲染任何符合您品牌的内容。

如果您不覆盖此控制器，SDK 会在令牌化、创建支付、3DS 和状态轮询期间显示全屏加载指示器。当您覆盖 `showView` 并将 SDK 的表单嵌入您自己的页面时，这同样适用：在 Android 上，加载指示器会覆盖您传给 `Transaction.start` 的 Activity，因此您的布局中不会渲染任何内容，并且在加载指示器显示期间返回操作会被吞掉。iOS 上有一个例外：当 `getPaymentMethodsViews` 返回的列表显示在屏幕上，且 SDK 没有呈现其自身的视图时，加载指示器就是该列表本身，会变暗并显示旋转图标，因此购物者仍能看到该列表。一旦 SDK 视图出现，加载指示器就会移到该视图上。

当您覆盖它时，SDK 不会显示其自身的加载指示器。相反，它会在进入加载状态时发出 `isLoading: true`，在离开时发出 `isLoading: false`。您根据这些值渲染自己的加载指示器。在 Web 上，请将每次调用视为当前状态（显示或隐藏），而不是对调用进行计数。headless 或 Secure Fields 的 `start()` 可能会在对应的 `false` 之前多次报告 `true`。

在单笔交易中，随着 SDK 进入和退出加载状态，该控制器可能会被多次调用。

在 iOS 上，您可以在某些流程中保留 SDK 的加载指示器，而在其他流程中显示您自己的加载指示器。在您的覆盖实现中调用 `SdkPayments.defaultShowLoading(isLoading:)` 即可运行默认行为：

```swift theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
func showLoading(isLoading: Bool) {
    guard usesOwnLoader else {
        SdkPayments.defaultShowLoading(isLoading: isLoading)
        return
    }
    spinner.isHidden = !isLoading
}
```

在 React Native 上，请在您的覆盖实现中调用 `SdkPayments.defaultShowLoading(isLoading)`：

```tsx theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
showLoading: (isLoading) => {
  if (!usesOwnLoader) {
    SdkPayments.defaultShowLoading(isLoading);
    return;
  }
  setLoading(isLoading);
},
```

## 签名

> [tab] Web
>
> ```typescript theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
> sdkPayments.transaction({
>   ...,
>   showLoading: (isLoading) => mySpinner.toggle(isLoading),
> })
> ```

> [tab] iOS
>
> ```swift theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
> func showLoading(isLoading: Bool)
> ```

> [tab] Android
>
> ```kotlin theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
> fun showLoading(isLoading: Boolean)
> ```

> [tab] React Native
>
> ```typescript theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
> showLoading?(isLoading: boolean): void
> ```

## 线程

在 iOS 和 Android 上，`showLoading` 在主线程上调用。您可以直接在此处理程序中更新 UI。在 React Native 上，它在 JavaScript 线程上运行：请在其中更新您的组件状态。

## 相关内容

* [`showView`](https://docs.y.uno/zh-hans/docs/yuno-sdk/controllers/show-view)（iOS、Android、React Native）。控制表单渲染。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.