Can't click on Admob ads on iPhone
I'm trying to show admob ads inside an iPhone App, which uses a TabBarController, with navigation controllers and tableviews. The ads are showing, but I can't click on them. Each tab inherits from a parent UIViewController class in which I initialize the ad with the following code:
bannerView = [[GADBannerView alloc]
initWithFrame:CGRectMake(0.0,
self.view.frame.size.height,
GAD_SIZE_320x50.width,
GAD_SIZE_320x50.height)];
bannerView.rootViewController = self;
[self.view addSubview:bannerView];
GADRequest *adRequest = [GADRequest request];
[bannerView loadRequest:adRequest];
This is the code in the adViewDidReceiveAd:aBannerView delegate method:
[UIView animateWithDuration:0.5
animations:^{
CGRect frame = CGRectMake(self.view.frame.origin.x,
self.view.frame.origin.y,
self.view.frame.size.width,
self.view.frame.size.height-48.0f);
self.view.frame = frame;
aBannerView.frame = CGRectMake(0.0,
frame.size.height,
aBannerView.frame.size.width,
开发者_如何学Go aBannerView.frame.size.height);
}];
If I put the Ad in front of the key window, the Ad is clickable, but doing it I can't make the proper animations to show it, and remains on top of all the windows, so I have to keep track of it with viewWillDisappear method. Is there a better way to do this?
Thank you in advance.
Well, the problem seems to be that I'm resizing the view frame, and putting the Ad outside this frame, so it can receive events. Seems to be solved resizing the first subview when I want to show the Ad:
UIView *subview = [[self.view subviews] objectAtIndex:0];
subview.frame = frame;
Also I have to keep track of tab changes using UITabBarControllerDelegate for hiding the Ad.
精彩评论