# 多重广告

&#x20;多重广告需要您自定义布局，适合列表或者瀑布流类型的布局中嵌套使用。

## 前提条件

* 通读[入门指南](/copy-of-cn/jie-kou-wen-dang/ios/kai-shi/ru-men-zhi-nan.md)

## 务必使用测试广告进行测试

在构建和测试应用时，请确保使用的是测试广告，而不是实际投放的广告。否则，可能会导致您的账号被暂停使用。对于 iOS 原生广告，使用下面的测试专用广告单元 ID：

```
63a573c07144f
```

该测试广告单元 ID 已经过专门配置，可确保每个请求返回的都是测试广告。您可以在自己应用的编码、测试和调试过程中随意使用该测试广告单元 ID。需要注意的一点是，请务必在发布应用前用您的广告单元 ID 替换该测试广告单元 ID。

## 接入步骤

* 请求广告
* 创建 Adx3CustomAdView
* 展示广告

## 请求广告

请求多重广告需要在 \[Adx3CustomAdManager manager] 上调用 loadCustomAdWithPlacementID:(NSString \*)placementID userId:(NSString \*)userId success:(void(^)(NSInteger adCount))success error:(void(^)(NSError \*error))error 方法完成，此方法需要您的广告单元 ID，userId 可不传或者传入您的应用为用户设置的 userId，最后通过回调告知您请求的结果，adCount是为您准备的广告数量。以下为代码示例：

{% tabs %}
{% tab title="Swift" %}

```swift
func loadCustomAd() {    
    Adx3CustomAdManager().loadCustomAd(withPlacementID: "Your Placement ID", userId: "") { adCount in
    
    } error: { error in
            
    }
}
```

{% endtab %}

{% tab title="Objective-C" %}

<pre class="language-objectivec"><code class="lang-objectivec"><strong>- (void)loadCustomAd {
</strong><strong>    [[Adx3CustomAdManager manager] loadCustomAdWithPlacementID:CUSTOM_ID userId:@"" success:^(NSInteger adCount) {
</strong>
    } error:^(NSError * _Nonnull error) {
    
    }];
<strong>}
</strong></code></pre>

{% endtab %}
{% endtabs %}

## 创建 Adx3CustomAdView

您需要自定义自己的 Adx3CustomAdView，相关子控件已为您申明，布局需要您自己手动定义

## 展示广告&#x20;

展示多重广告需要在 \[Adx3CustomAdManager manager] 上调用 loadCustomAdView:(Adx3CustomAdView \*)customAdView index:(NSInteger)index location:(CGPoint)location 方法完成，此方法需要您提供自定义的 Adx3CustomAdView, index 为 Adx3CustomAdView 的下标，location 为当您触摸 Adx3CustomAdView 时，它在屏幕上所处的位置，此目的是为了能够为您提供更精准的多重广告服务。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.adx3.io/copy-of-cn/jie-kou-wen-dang/ios/guang-gao-ge-shi/duo-chong-guang-gao.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
