簡體   English   中英

為什么我的AdMob代碼在我的iPhone應用程序中泄漏?

[英]Why is my AdMob code leaking in my iphone app?

我已經在我的iPhone應用程序中添加了AdMob。 我的viewDidLoad方法中有以下代碼:

bannerView_ = [[GADBannerView alloc]
               initWithFrame:CGRectMake(0.0,
                                        0.0,
                                        320,
                                        50)];



// Specify the ad's "unit identifier." This is your AdMob Publisher ID.
bannerView_.adUnitID = ADMOB_BANNER_UNIT_ID;

// Let the runtime know which UIViewController to restore after taking
// the user wherever the ad goes and add it to the view hierarchy.
bannerView_.rootViewController = self;
[self.view addSubview:bannerView_];

// Initiate a generic request to load it with an ad.
GADRequest *r = [[GADRequest alloc] init];
r.testing = YES;
[bannerView_ loadRequest:r];
[r release];

這漏了。 當我注釋掉倒數第二行([bannerView_ loadRequest:r];)時,泄漏消失了。 我在Google提供的示例中的這段代碼中唯一更改的是引入變量r,以便可以將AdMob置於測試模式。 在Google提供的代碼中,bannerView_由viewDidUnload發布。 我尋找了loadRequest方法,但發現的只是GADBannerView.h文件中的定義。 據我所知,沒有GADBannerView.m文件,它本身似乎很奇怪。 無論如何,任何提示將不勝感激。

謝謝,

約翰

您為什么不使用此AdMediator-配置非常簡單,您不必擔心AdMob和iAd(如果要使用它):

如果沒有可用的iAd,則會交換AdMob廣告。

您是在dealloc方法中還是其他合適的位置釋放bannerView_?

代替:

GADRequest *r = [[GADRequest alloc] init];

您可以嘗試:

GADRequest *r = [GADRequest request];

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM