如何将 AdMob 广告放置在标签栏上方?
我已获得 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
你可以试试这个;
使用 100 以下的任何其他数字将横幅向上移动。希望这对你有用!
You can try this;
use any other number below of 100 to move the banner up. Hope this work for you!