我使用此代码在横向游戏中显示 GADAppOpenAd ..但广告没有横向显示。
- (void)requestAppOpenAd {
self.appOpenAd = nil;
[GADAppOpenAd loadWithAdUnitID:ADMOB_APP_OPEN_ID
request:[GADRequest request]
orientation:UIInterfaceOrientationPortrait
completionHandler:^(GADAppOpenAd *_Nullable appOpenAd, NSError *_Nullable error) {
if (error) {
NSLog(@"Failed to load app open ad: %@", error);
return;
}
self.appOpenAd = appOpenAd;
self.appOpenAd.fullScreenContentDelegate = self;
}];
}
- (void)tryToPresentAd
{
if(g_show_ads)
{
if (self.appOpenAd) {
UIViewController *rootController = self.window.rootViewController;
[self.appOpenAd presentFromRootViewController:rootController];
} else {
// If you don't have an ad ready, request one.
[self requestAppOpenAd];
}
}
}