2017-07-10 2 views
0

Chaque fois que je la catégorie ouverte interstitiel semble que je veux faire, il semble une foisComment afficher interstitiel une fois dans l'application ios?

le code

//----------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

vous devez en viewDidLoad initialiser. car GADInterstitial est un objet d'utilisation unique. – KKRocks

Répondre

0

Essayez cette

static dispatch_once_t onceToken; 
    dispatch_once(&onceToken, ^{ 
//call your method here 
    [self createAndLoadInterstitial]; 
    }); 
+0

il me donne erreur – heythem500

+0

quelle erreur? vérifier édité – karthikeyan

+0

Je suis amateur devrais-je mettre cela avant le code? – heythem500