Question

Im currently implementing iAd in my first iPhone app. My issue, which i'm having, is to detect if there is actually an interstitial ad showing on my view controller. Because, if there is no ad i would like to show another view.

I have been reading through the iAd programming guide and then found the 'UIViewController iAd Additions Reference' in the docs. This one tells me, my view controller has now a new property called presentingFullScreenAd.

The problem is whenever i call it in viewDidLoad, viewWillAppear or viewDidAppear it returns NO. Except when i close the ad (if there was an ad showing) than it returns YES in viewWillAppear and viewDidAppear but its too late then.

I have set the interstitialPresentationPolicy of the view controller which is showing the ad to ADInterstitialPresentationPolicyAutomatic because i want it to show the ad as often as possible.

Any ideas about this? Thanks in advance.

Était-ce utile?

La solution

You may want to setup a timer to cancel the request for an interstitial ad after a certain amount of time so that you can show the next view if an ad is not filled promptly. Prior to an interstitial ad being shown interstitialAdDidLoad is invoked. So, if the ad has loaded, the ad is now on screen until it is dismissed where interstitialAdDidUnload and interstitialAdActionDidFinish will be called. Listen to these delegate methods to determine if an interstitial ad is on the screen currently.

-(void)interstitialAdDidLoad:(ADInterstitialAd *)interstitialAd {
    NSLog(@"interstitialAdDidLOAD");

    [interstitial presentFromViewController:self];
    NSLog(@"interstitialAdDidPRESENT");
}

-(void)interstitialAdDidUnload:(ADInterstitialAd *)interstitialAd {
    NSLog(@"interstitialAdDidUNLOAD");
}

-(void)interstitialAdActionDidFinish:(ADInterstitialAd *)interstitialAd {
    NSLog(@"interstitialAdDidFINISH");
}

Also, refer to UIViewController iAd Additions Reference.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top