2

最近、全画面表示の iAd は iPad でしか動作しないという記事を読みました。ADInterstitialAdフルスクリーン iAd の開発に使用するこのクラス。でデリゲート メソッドを実装する方法はADInterstitialAdDelegate?

4

1 に答える 1

0

これを使用してフルスクリーン iAd を作成できます

.H ファイル内

輸入

#import <iAd/iAd.h>

@interface ViewController : UIViewController<ADInterstitialAdDelegate>
{
    ADInterstitialAd *interstitial;
}

in.Mファイル

@interface ViewController ()

// Interstitials
- (void)cycleInterstitial;

@implementation ViewController

- (void)cycleInterstitial
{
    // Clean up the old interstitial...
    interstitial.delegate = nil;
    // and create a new interstitial. We set the delegate so that we can be notified of when
    interstitial = [[ADInterstitialAd alloc] init];
    interstitial.delegate = self;
}


#pragma mark ADInterstitialViewDelegate methods

// When this method is invoked, the application should remove the view from the screen and tear it down.
// The content will be unloaded shortly after this method is called and no new content will be loaded in that view.
// This may occur either when the user dismisses the interstitial view via the dismiss button or
// if the content in the view has expired.
- (void)interstitialAdDidUnload:(ADInterstitialAd *)interstitialAd
{
    [self cycleInterstitial];
}

// This method will be invoked when an error has occurred attempting to get advertisement content.
// The ADError enum lists the possible error codes.
- (void)interstitialAd:(ADInterstitialAd *)interstitialAd didFailWithError:(NSError *)error
{
    [self cycleInterstitial];
}

// if you want to show iAd while pushing view controller just use
- (IBAction)onSearchClick:(id)sender {
     if (interstitial.loaded) {
        //        [interstitial presentFromViewController:self]; // deprecated in iOS 6.
        [self requestInterstitialAdPresentation]; // it will load iAD Full screen mode.
    }
// do whatever you want to do.
}

楽しいコーディングを。乾杯。

于 2014-04-11T19:33:20.790 に答える