繁体   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