【问题标题】:How much space should I leave out for a bottom Admob banner?我应该为底部的 Admob 横幅留出多少空间?
【发布时间】:2016-07-07 13:39:10
【问题描述】:

我在屏幕底部为 admob 横幅留出了大约 100(不知道单位)的高度,它将在项目结束时添加。

对于 iphone 6,admob 横幅的高度约为 100。

但是,当我移动到 ipad 时,这个高度就不同了。

所以有些元素的位置不同(高度方向)。

例如:

float admobHeight = 100.0;

Vec2 desiredPosition = Vec2(0, 100);

auto sprite = Sprite::create("image.png");
sprite->setAnchorPoint(Vec2(0, 0));

// Leave out space for the bottom Admob banner.
sprite->setPosition(Vec2(desiredPosition.x, desiredPosition.y + admobHeight));

this->addChild(sprite);

我将 DesignResolution 设置为:

(AppDelegate.cpp)

static cocos2d::Size designResolutionSize = cocos2d::Size(768, 1136);

和解决政策 NO_BORDER:

glview->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, ResolutionPolicy::NO_BORDER);

如何在屏幕底部为每种类型的设备留出适当的高度空间以供 Admob 使用?

【问题讨论】:

标签: c++ cocos2d-iphone cocos2d-x cocos2d-x-3.0 cocos2d-android


【解决方案1】:

标准横幅高度为 60 像素 这是admob横幅集成的代码

bannerView_ = [[GADBannerView alloc] initWithFrame:CGRectMake(0, viewController.view.frame.size.height-60, viewController.view.frame.size.width, 60)]; bannerView_.center = CGPointMake(viewController.view.frame.size.width/2.f, viewController.view.frame.size.height-30); bannerView_.adUnitID = ADMOB_BANNER_ID;

    bannerView_.rootViewController=self.viewController;

    //[UIViewController:addSubview:bannerView_];
    [viewController.view addSubview:bannerView_];
    // Initiate a generic request to load it with an ad.
    [bannerView_ loadRequest:[GADRequest request]];

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多