# 多重广告

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

## 前提条件

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

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

在构建和测试应用时，请确保使用的是测试广告，而不是实际投放的广告。否则，可能会导致您的账号被暂停使用。对于 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 时，它在屏幕上所处的位置，此目的是为了能够为您提供更精准的多重广告服务。
