【问题标题】:How do I position AdMob ad above the Tabbar?如何将 AdMob 广告置于 Tabbar 上方?
【发布时间】:2011-07-28 08:59:15
【问题描述】:

我已获得最新版本的 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

【问题讨论】:

  • 所以我看到了一个使用 TableView 的建议,但我不想为这个 App 使用 TableView。还有其他选择吗?
  • 好吧,我继续研究这个,因为我在这里看到的答案不多。如果我找到它,我会发布一个。
  • 我正在切换到 iAd 看看能否解决。

标签: iphone ipad admob tabbar ios4


【解决方案1】:

你可以试试这个;

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

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

【讨论】:

    猜你喜欢
    • 2013-12-18
    • 1970-01-01
    • 2019-09-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-07
    • 1970-01-01
    • 2012-09-23
    相关资源
    最近更新 更多