Skip to content
On this page

Banner 广告

*Banner广告回调说明

// banner 广告加载成功
- (void)juHeBaoBannerAdViewDidLoad:(JuHeBaoBannerAd *_Nonnull)bannerAdView;

// banner 广告加载失败
- (void)juHeBaoBannerAdView:(JuHeBaoBannerAd *_Nonnull)bannerAdView didLoadFailWithError:(NSError *_Nullable)error;

// banner 广告已经展示
- (void)juHeBaoBannerAdViewDidBecomeVisible:(JuHeBaoBannerAd *_Nonnull)bannerAdView;

// banner 广告被点击
- (void)juHeBaoBannerAdViewDidClick:(JuHeBaoBannerAd *_Nonnull)bannerAdView;

// banner 广告视图被移除
- (void)juHeBaoBannerAdViewDidRemoved:(JuHeBaoBannerAd *_Nonnull)nativeExpressAdView;

*Banner广告使用示例
广告加载
1.Objective-C

- (void)loadJuHeBaoBannerAd {
JuHeBaoBannerAd *juHeBaoBannerAd = [[JuHeBaoBannerAd alloc] init];

- (void)loadJuHeBaoBannerAd {
    [self.bannerView removeFromSuperview];
    
    juHeBaoBannerAd.slotID = @"102441315";
    juHeBaoBannerAd.adSize = CGSizeMake(375, 150);
    juHeBaoBannerAd.delegate = self;
    [juHeBaoBannerAd loadJuHeBaoAdData:self];
}

}

2.Swift

let juHeBaoBannerAd = JuHeBaoBannerAd()
    func loadJuHeBaoBannerAd(){
        self.bannerView.removeFromSuperview()
       self.juHeBaoBannerAd.slotID = "102441315"
       self.juHeBaoBannerAd.adSize = CGSize(width: 375, height: 150)
       self.juHeBaoBannerAd.delegate = self
       self.juHeBaoBannerAd.loadJuHeBaoAdData(self)
    }

广告展示
1.Objective-C

CGFloat bottom = 0.0;
if (@available(iOS 11.0, *)) {
    UIWindow *window = [[[UIApplication sharedApplication] windows] firstObject];
    bottom = window.safeAreaInsets.bottom;
}

CGSize size = CGSizeMake(375, 150);
self.bannerView.frame = CGRectMake((self.view.bounds.size.width - size.width) / 2.0,
                                    self.view.bounds.size.height - size.height - bottom,
                                    size.width,
                                    size.height);
[self.bannerView addSubview:bannerAdView];
[self.view addSubview:bannerView];

2.Swift

var bottom: CGFloat = 0.0
          if #available(iOS 11.0, *) {
              if let window = UIApplication.shared.windows.first {
                  bottom = window.safeAreaInsets.bottom
              }
          }
          let size = CGSize(width: 375, height: 150)
          self.bannerView.frame = CGRect(x: (self.view.bounds.width - size.width) / 2.0, y: self.view.bounds.height - size.height - bottom, width: size.width, height: size.height)
          bannerView.addSubview(bannerAdView)
          self.view.addSubview(bannerView)