gpt4 book ai didi

iphone - 如何将 Admob 横幅放在 iPhone 4S 和 iPhone 5 的底部?

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:04:00 26 4
gpt4 key购买 nike

在 iPhone 5 之前,我可以将 admob 横幅放置在屏幕底部(标签栏正上方)。但由于 iPhone 5 的屏幕尺寸,现在一切都被打乱了。我什至尝试通过自动布局来完成(它没有用)。我怎样才能为两种屏幕尺寸做到这一点?

这是我的代码 -

-(void) viewDidLoad {

[super viewDidLoad];

adMob = [[GADBannerView alloc] initWithFrame:CGRectMake(0.0,
367.0 -
GAD_SIZE_320x50.height,
GAD_SIZE_320x50.width,
GAD_SIZE_320x50.height)];

adMob.translatesAutoresizingMaskIntoConstraints=NO;

// Specify the ad's "unit identifier." This is your AdMob Publisher ID.
adMob.adUnitID = @"XXXXXXXX";



// Let the runtime know which UIViewController to restore after taking
// the user wherever the ad goes and add it to the view hierarchy.
adMob.rootViewController = self;
GADRequest *request = [GADRequest request];

request.testing=YES;
[self.view addSubview:adMob];

// Initiate a generic request to load it with an ad.
[adMob loadRequest:[GADRequest request]];
[adMob release];

// Create a view of the standard size at the bottom of the screen.
// Available AdSize constants are explained in GADAdSize.h.


}

任何帮助将不胜感激!

最佳答案

如果您使用的是 iOS 6,您应该只使用 AutoLayout。在将横幅添加到 View 层次结构后,您可以将此代码放入广告展示位置代码中:

self.googleAdBannerView.translatesAutoresizingMaskIntoConstraints = NO;
[self.view addSubview:self.googleAdBannerView];

// Constraint keeps ad at the bottom of the screen at all times.
[self.googleAdBannerView.bottomAnchor constraintEqualToAnchor:self.view.bottomAnchor].active = YES;

// Constraint keeps ad in the center of the screen at all times.
[self.googleAdBannerView.centerXAnchor constraintEqualToAnchor:self.view.centerXAnchor].active = YES;

关于iphone - 如何将 Admob 横幅放在 iPhone 4S 和 iPhone 5 的底部?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13200601/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com