【问题标题】:AppLovin Banner Ad Crash on iPadAppLovin 横幅广告在 iPad 上崩溃
【发布时间】:2013-07-13 21:29:53
【问题描述】:

我正在尝试将 AppLovin 横幅广告集成到我的通用应用程序中。在 iPhone 上,它运行良好。但是在 iPad 上,在用户离开/关闭带有横幅的视图后,应用程序会崩溃。

这是显示横幅广告的代码:

// Create new AdView
adView = [[ALAdView alloc] initBannerAd];

//
// (Optional) Position the ad at the bottom of screen. By default
// it would be postitioned at (0,0)
//
adView.frame = CGRectMake( 0,
                          self.view.frame.size.height - adView.frame.size.height,
                          adView.frame.size.width,
                          adView.frame.size.height );

adView.autoresizingMask =
UIViewAutoresizingFlexibleLeftMargin |
UIViewAutoresizingFlexibleTopMargin |
UIViewAutoresizingFlexibleWidth |
UIViewAutoresizingFlexibleRightMargin;

// (Mandatory) Add the ad into current view
[self.view addSubview:adView];

// (Mandatory) Trigger loading of the new ad.
[adView loadNextAd];

如果我注释掉 addSubview 调用,则不会发生崩溃。似乎添加的子视图没有被统一化或其他东西。

非常感谢您的帮助!

【问题讨论】:

  • 供未来用户使用...将其移至顶部... adView.frame = CGRectMake( 0, 0, adView.frame.size.width, adView.frame.size.height );

标签: ios ipad uitableview uiviewcontroller applovin


【解决方案1】:

问题是没有指定父控制器。添加

adView.parentController = self;

解决了这个问题。这是最终代码:

// Create new AdView
adView = [[ALAdView alloc] initBannerAd];
adView.parentController = self;

// (Optional) Position the ad at the bottom of screen.
// By default it would be postitioned at (0,0)
adView.frame = CGRectMake( 0,
                          self.view.frame.size.height - adView.frame.size.height,
                          adView.frame.size.width,
                          adView.frame.size.height );

adView.autoresizingMask =
UIViewAutoresizingFlexibleLeftMargin |
UIViewAutoresizingFlexibleTopMargin |
UIViewAutoresizingFlexibleWidth |
UIViewAutoresizingFlexibleRightMargin;

// (Mandatory) Add the ad into current view
[self.view addSubview:adView];

// (Mandatory) Trigger loading of the new ad.
[adView loadNextAd];

【讨论】:

  • “initBannerAd”现在被标记为已弃用...什么是更新代码?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2022-08-14
  • 2021-02-26
  • 1970-01-01
  • 1970-01-01
  • 2020-06-24
  • 1970-01-01
  • 2020-11-20
相关资源
最近更新 更多