iPhone-处理AdMob广告定向

iPhone-处理AdMob广告定向,iphone,admob,Iphone,Admob,我在应用程序中集成了AdMob。广告显示在视图的底部。 我的应用程序支持纵向和横向模式。 当方向改变时,我如何确保广告仅显示在底部? 我想在两个方向上展示广告 任何解决方法请…您需要在GadbanerView上设置自动调整大小位掩码,以便在设备改变方向时使上边距灵活。假设您的GadbanerView名为“bannerView”,请尝试: 在横向模式下,GadbanerView不会覆盖整个屏幕宽度。例如,如果要将其居中放置在底部,请尝试: [bannerView_ setAutoresiz

我在应用程序中集成了AdMob。广告显示在视图的底部。 我的应用程序支持纵向和横向模式。 当方向改变时,我如何确保广告仅显示在底部? 我想在两个方向上展示广告


任何解决方法请…

您需要在GadbanerView上设置自动调整大小位掩码,以便在设备改变方向时使上边距灵活。假设您的GadbanerView名为“bannerView”,请尝试:

在横向模式下,GadbanerView不会覆盖整个屏幕宽度。例如,如果要将其居中放置在底部,请尝试:

    [bannerView_ setAutoresizingMask:UIViewAutoresizingFlexibleTopMargin|UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleRightMargin];

您可以使用这些自动调整大小的位使其适用于您的应用程序。

您需要在GadbanerView上设置自动调整大小的位掩码,以便在设备改变方向时使上边距灵活。假设您的GadbanerView名为“bannerView”,请尝试:

在横向模式下,GadbanerView不会覆盖整个屏幕宽度。例如,如果要将其居中放置在底部,请尝试:

    [bannerView_ setAutoresizingMask:UIViewAutoresizingFlexibleTopMargin|UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleRightMargin];

您可以使用这些自动调整大小的功能使其适用于您的应用程序。

这是我在横向模式下将AdMob广告置于屏幕底部中心的代码:

int x = (self.view.frame.size.width - CGSizeFromGADAdSize(kGADAdSizeBanner).width) / 2;
int y = self.view.frame.size.height - CGSizeFromGADAdSize(kGADAdSizeBanner).height - 2;

CGPoint origin = CGPointMake(x, y);

bannerScore = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner origin:origin];

bannerScore.adUnitID = @"xxxxxxxx";

bannerScore.rootViewController = self;
[self.view addSubview:bannerScore];

[bannerScore loadRequest:[GADRequest request]];

这是我在横向模式下将AdMob广告置于屏幕底部中心的代码:

int x = (self.view.frame.size.width - CGSizeFromGADAdSize(kGADAdSizeBanner).width) / 2;
int y = self.view.frame.size.height - CGSizeFromGADAdSize(kGADAdSizeBanner).height - 2;

CGPoint origin = CGPointMake(x, y);

bannerScore = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner origin:origin];

bannerScore.adUnitID = @"xxxxxxxx";

bannerScore.rootViewController = self;
[self.view addSubview:bannerScore];

[bannerScore loadRequest:[GADRequest request]];