每次我打开类别的间隙出现,我想让它出现一次
代码
//----------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");
}发布于 2017-07-10 19:38:20
尝尝这个
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
//call your method here
[self createAndLoadInterstitial];
});https://stackoverflow.com/questions/45010921
复制相似问题