2011-06-16 67 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];