I use the Google AdMob SDK (the last one downloaded most recently) in my application.
When my application launches it, it freezes for 4-5 seconds until the ad is loaded and displayed. After that, it works smoothly. When I comment out the banner request line, the application starts normally.
I created my own 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]; }
Where
- googleBannerView is a property of my class and is of type GADBannerView
- I set the frame size and ad unit ID correctly
- targetController is a controller. I want to add a banner to
- I call the [CustomClass getGoogleBanner: self] method in the viewDidAppear of various controllers and successfully display the banner, except for the first loading problem.
I would like to know if anyone has encountered this problem and how it is resolved. I am open to any ideas that would fix the freeze problem. I tried to run the code in the background thread, but I failed because I am not very good at it.
Any help is greatly appreciated, thanks in advance.
Murat Ögat
source share