2011-06-16 65 views
0

我已將AdMob包含在我的iPhone應用程序中。我在我的viewDidLoad方法中有以下代碼:爲什麼我的AdMob代碼在iPhone應用程序中泄漏?

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];)時,泄漏消失。我從谷歌提供的例子中唯一改變的代碼是引入了變量r,因此我可以將AdMob置於測試模式。在Google提供的代碼中,bannerView_由viewDidUnload發佈。我查找了loadRequest方法,但是我找到的只是GADBannerView.h文件中的一個定義。據我所知,沒有GADBannerView.m文件,這本身似乎很奇怪。無論如何,任何提示將不勝感激。

感謝,

約翰

回答

0

你爲什麼不利用這個AdMediator - 它是配置非常簡單,你不必擔心AdMob和iAds的(如果你想使用它) :

將交換AdMob廣告,如果沒有iAds是 可用。

0

你在dealloc方法或其他適當的地方發佈bannerView_嗎?

相反的:

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

你可以嘗試:

GADRequest *r = [GADRequest request];