1
我一直试图展示admob插页式广告没有运气的周,我已经设法显示正常的横幅广告,但我不知道正确的方式来显示插页式广告,这里是我试过的代码(遵循admob指南)admob插页式广告在ios上不显示?
在我mainViewcontroller.h
@interface MainViewController : CDVViewController
<GADBannerViewDelegate> {
GADBannerView *adBanner_;
GADInterstitial *interstitial_;
}
和我mainViewController.m
@implementation MainViewController
@synthesize adBanner = adBanner_;
#pragma mark init/dealloc
// Implement viewDidLoad to do additional setup after loading the view,
// typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
interstitial_ = [[GADInterstitial alloc] init];
interstitial_.adUnitID = @"XXXXXXXXXXXXXX";
[interstitial_ loadRequest:[GADRequest request]];
[interstitial_ presentFromRootViewController:self];
// Initialize the banner at the bottom of the screen.
[adBanner_ setFrame:CGRectMake(100,
100,
adBanner_.bounds.size.width,
adBanner_.bounds.size.height)];
// Use predefined GADAdSize constants to define the GADBannerView.
self.adBanner = [[[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner
]
autorelease];
// Note: Edit SampleConstants.h to provide a definition for kSampleAdUnitID
// before compiling.
self.adBanner.adUnitID = @"XXXXXXXXXXXXXXX";
self.adBanner.delegate = self;
[self.adBanner setRootViewController:self];
[self.view addSubview:self.adBanner];
self.adBanner.center =
CGPointMake(self.view.center.x, self.adBanner.center.y);
[self.adBanner loadRequest:[self createRequest]];
}
您必须将DFPInterstitial更改为GADInterstitial !!!!然后它工作正常! - (void)interstitialDidReceiveAd:(GADInterstitial *)ad { [interstitial_ presentFromRootViewController:self]; } – basti12354