如何将 AdMob 广告放置在标签栏上方?

发布于 10-29 01:03 字数 2047 浏览 7 评论 0原文

我已获得 AdMob 的最新版本 iOS 代码。它工作正常,但广告显示在我的标签栏下。如何将广告移至栏上方?这是我的相关代码:

#import "InformationViewController.h"


@implementation InformationViewController

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
    // Create a view of the standard size at the bottom of the screen.

    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) 
    {
        /* run something specific for the iPad */
        bannerView_ = [[GADBannerView alloc]
                       initWithFrame:CGRectMake(0.0,
                                                self.view.frame.size.height -
                                                GAD_SIZE_300x250.height,
                                                GAD_SIZE_300x250.width,
                                                GAD_SIZE_300x250.height)];
    } 
    else
    {
        /* run something specific for the iPhone */
        bannerView_ = [[GADBannerView alloc]
                       initWithFrame:CGRectMake(0.0,
                                                self.view.frame.size.height -
                                                GAD_SIZE_320x50.height,
                                                GAD_SIZE_320x50.width,
                                                GAD_SIZE_320x50.height)];
    }

    // Specify the ad's "unit identifier." This is your AdMob Publisher ID.
    bannerView_.adUnitID = MY_BANNER_UNIT_ID;

    // Let the runtime know which UIViewController to restore after taking
    // the user wherever the ad goes and add it to the view hierarchy.
    bannerView_.rootViewController = self;
    [self.view addSubview:bannerView_];

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

和我的头文件 -

#import "GADBannerView.h"

#import <UIKit/UIKit.h>


@interface InformationViewController : UIViewController {

    GADBannerView *bannerView_;

}

@end

I've gotten the latest version of the iOS code for AdMob. It is working fine, but the ad shows up under the tabbar I have. How do I move the ad up above the bar? Here's my relevant code:

#import "InformationViewController.h"


@implementation InformationViewController

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
    // Create a view of the standard size at the bottom of the screen.

    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) 
    {
        /* run something specific for the iPad */
        bannerView_ = [[GADBannerView alloc]
                       initWithFrame:CGRectMake(0.0,
                                                self.view.frame.size.height -
                                                GAD_SIZE_300x250.height,
                                                GAD_SIZE_300x250.width,
                                                GAD_SIZE_300x250.height)];
    } 
    else
    {
        /* run something specific for the iPhone */
        bannerView_ = [[GADBannerView alloc]
                       initWithFrame:CGRectMake(0.0,
                                                self.view.frame.size.height -
                                                GAD_SIZE_320x50.height,
                                                GAD_SIZE_320x50.width,
                                                GAD_SIZE_320x50.height)];
    }

    // Specify the ad's "unit identifier." This is your AdMob Publisher ID.
    bannerView_.adUnitID = MY_BANNER_UNIT_ID;

    // Let the runtime know which UIViewController to restore after taking
    // the user wherever the ad goes and add it to the view hierarchy.
    bannerView_.rootViewController = self;
    [self.view addSubview:bannerView_];

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

And my header file -

#import "GADBannerView.h"

#import <UIKit/UIKit.h>


@interface InformationViewController : UIViewController {

    GADBannerView *bannerView_;

}

@end

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

明媚殇2024-11-05 01:03:58

你可以试试这个;

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

使用 100 以下的任何其他数字将横幅向上移动。希望这对你有用!

You can try this;

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

use any other number below of 100 to move the banner up. Hope this work for you!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文