每当我打开类别时,插页式广告显示我想让它显示一次
代码
//----------Interstitial Initialization-------------//
-(void)createAndLoadInterstitial
{
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
_interstitial = [[GADInterstitial alloc] initWithAdUnitID:appDelegate.InterstitialAdUnitID];
_interstitial.delegate = self;
[_interstitial loadRequest:[GADRequest request]];
}
- (void)interstitialDidReceiveAd:(GADInterstitial *)interstitial
{
[_interstitial presentFromRootViewController:self];
}
- (void)interstitial:(GADInterstitial *)interstitial didFailToReceiveAdWithError:(GADRequestError *)error
{
NSLog(@"interstitialDidFailToReceiveAdWithError: %@", [error localizedDescription]);
}
- (void)interstitialDidDismissScreen:(GADInterstitial *)interstitial
{
NSLog(@"interstitialDidDismissScreen");
}
答案 0 :(得分:0)
试试这个
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
//call your method here
[self createAndLoadInterstitial];
});