Admob ads do not appear in the UITableView footer when the keyboard is displayed

I use this to show Admob ads on a UITableView footer:

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section { GADBannerView *sampleView = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner]; if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { sampleView.hidden=true; } sampleView.adUnitID = @"myID"; sampleView.rootViewController = self; [sampleView loadRequest:[GADRequest request]]; return sampleView; } - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section { return 50.0; } 

I do not have a real iPhone device, so I only test it on simulators. The above code works if the software keyboard is hidden and I typed that word using the MacBook keyboard. However, when I open the soft keyboard in the simulator, the ads do not load in the footer. Instead, it loads under the search bar. How do i solve this? I do not know if this error occurred in a real device.

Admob no in footer

+7
ios objective-c iphone uitableview admob
source share
1 answer

I need a higher comment for comments, but the problem may be related to how you create the GADBannerView.

As you know, the delegate -tableView:viewForFooterInSection: is called whenever a footer view is required. If you view this view off-screen and back again, the delegate starts again.

Creating a GADBannerView in the delegate method -tableView:viewForFooterInSection: will create a new advertisement each time you scroll forward and backward, and a new request will be sent.

My suggestion is to move the creation of the GADBannerView to the -viewDidLoad: ViewController method and return the same instance each time.

 @interface MyViewController () @property (nonatomic, strong) GADBannerView *footerAdView; @property (nonatomic, assign, getter=isFooterAdRequested) BOOL footerAdRequested; @end @implementation MyViewController ... -(void)viewDidLoad:(BOOL)animated { self.footerAdView = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner]; _footerAdView.adUnitID = @"myID"; _footerAdView.rootViewController = self; } ... - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section { if(![self isFooterAdFetched]) { [_footerAdView loadRequest:[GADRequest request]]; self.footerAdRequested = YES; // Set this to NO again when ad is dismissed/closed/ended so that a new ad can be requested only when the current one is done. } return _footerAdView; } ... @end 

Even if my vague assumption does not help you, perhaps this example will help you keep the same type of advertising and be a little nicer for the user, without changing the ad every time the user scrolls back and forth.

My vague guess:

I have never worked with Google Ads, so I can’t tell you if they are trying to process ads without being properly attached to the hierarchy of views. My suspicion was that a shot ad (covered with a keyboard so that a new one is loading) somehow becomes inappropriate.

+2
source share

All Articles