Emanuel
Emanuel

Reputation: 1861

Pause ad refresh admob ios

How can I pause an ad when the user has selected another tab? I have a tabbed iOS app, I noticed the ads are refreshing even when the tab in which they are isn't visible. I've looked all over the place and haven't found anything to pause the auto refresh. Is it a good measure to remove and nullify the ad when the user leaves a tab?

Upvotes: 3

Views: 1776

Answers (1)

Emanuel
Emanuel

Reputation: 1861

I found out that removing the GADBannerView from the superview (without releasing it, just removing it and keeping it safe with a strong property) prevents the ad from refreshing, so I'm doing this:

-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [self.view addSubview:self.adView];
}
-(void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    [self.adView removeFromSuperview];
}

Upvotes: 1

Related Questions