谷歌的AdMob GADBannerView第一个请求需要很长的时间,并冻结UI第一个、很长、时间、AdMob

2023-09-09 22:05:57 作者:墨尔本ˇ晴

我在我的应用程序中使用谷歌AdMob的SDK(最新一期下载刚刚)。

I'm using Google AdMob SDK (latest one downloaded just recently) in my app.

在我的应用程序启动冻结为4-5秒,直到广告加载并显示。此后,它运行顺利。当我注释掉的旗帜请求行,应用程序正常启动。

When my app launches it freezes for 4-5 seconds, until the ad is loaded and displayed. Afterwards it runs smoothly. When I comment out the banner request line, the app starts normally.

我做了一个自定义的辅助类,其中我有以下的code。

I have made a custom helper class, in which I have the following code.

- (void) getGoogleBanner:(UIViewController *) targetController
{
    self.googleBannerView.rootViewController = targetController;
    [self.googleBannerView.rootViewController.view addSubview:self.googleBannerView];
    [self.googleBannerView setDelegate:self];
    GADRequest* request = [GADRequest request];
    [self.googleBannerView loadRequest:request];
}

其中

googleBannerView是我的类的属性,并具有类型GADBannerView 我设置帧大小和广告单元ID事先妥善 targetController是我想要的旗帜添加到控制器 我叫[CustomClass getGoogleBanner:个体经营]方法viewDidAppear各种不同的控制器,并成功地展示旗帜,除了第一负载问题。

我想知道是否有人遇到了这个问题,它是如何解决的。我接受任何想法,将删除冻结的问题。我试着运行code到后台线程,但我失败了,因为我不太了解它。

I'd like to know if anyone has run into this problem, and how it is solved. I'm open to any ideas that would remove the freezing issue. I tried to running the code to a background thread, but I failed because I'm not very experienced with it.

任何帮助是非常AP preciated,在此先感谢。

Any help is much appreciated, thanks in advance.

推荐答案

我有问题仅在模拟器中运行时,因此,如果是这样的话,你不应该担心可能。

I've got the issue only when running in the simulator, so if this is the case, you shouldn't probably worry.

这是我能找到,调用 loadRequest 方法时,该框架也将调用 canOpenURL:办法( 的UIApplication )。从一些测试,我跑(在两个模拟器和iOS设备与5.1.1和6.1.3), canOpenURL 偶尔会停顿在模拟器上几秒钟(一旦它把它20秒返回),但是,效果很好上的设备。

From what I could find, when calling the loadRequest method, the framework will also call canOpenURL: method (UIApplication). From some tests that I ran (on both simulator and iOS devices with 5.1.1 and 6.1.3), canOpenURL occasionally freezes for few seconds on the simulator (once it took it 20 seconds to return), however, works well on the devices.

 
精彩推荐
图片推荐