[英]AdMob banner position on ios app
i'm working on a ios app that is so structured: 我正在使用结构如此的ios应用程序:
mainNavigation(navigation controller for mainapp-login)->tabBarController(3 tab bar item)->NavigationController(navigation contronoller for every tab bar item). mainNavigation(用于mainapp登录的导航控制器)-> tabBarController(3个选项卡栏项)-> NavigationController(每个选项卡栏项的导航控件)。
I want add admob in the top of my app(in the top of my navigation bar...). 我想在应用程序顶部(在导航栏顶部...)添加admob。 In my viewDidLoad of a tab bar item, i did this:
在标签栏项目的viewDidLoad中,我这样做:
- (void)viewDidLoad
{
[super viewDidLoad];
//bannerView_ = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner];
bannerView_ = [[GADBannerView alloc]
initWithFrame:CGRectMake(0.0,
70.0 -
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 = @"ID";
bannerView_.rootViewController = self;
[self.navigationController.view addSubview:bannerView_];
[bannerView_ loadRequest:[GADRequest request]];
}
The banner, hide the navigation bar, like so: http://cl.ly/image/3C2S0m040O2h Instead if i don't use: 标语,隐藏导航栏,如下所示: http : //cl.ly/image/3C2S0m040O2h相反,如果我不使用:
bannerView_ = [[GADBannerView alloc]
initWithFrame:CGRectMake(0.0,
70.0 -
GAD_SIZE_320x50.height,
GAD_SIZE_320x50.width,
GAD_SIZE_320x50.height)];
But use: 但是使用:
bannerView_ = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner];
Look so: http://cl.ly/image/203v1C2W1b2P Instead i want that banner is showed in top, and all content(also the navigation bar)...go below the banner. 看起来是这样: http : //cl.ly/image/203v1C2W1b2P相反,我希望该横幅显示在顶部,并且所有内容(还有导航栏)...都在横幅下方。 How i can do ?
我该怎么办? Thanks, and sorry for my bad english.
谢谢,对不起,我的英语不好。
NavigationBar must be on the top, you can't change it position . NavigationBar必须在顶部,您不能更改其position。
Hide default navigationBar 隐藏默认导航栏
[self.navigationController setNavigationBarHidden:YES];
Then create faked NavigationBar(subclass of UIView) and place it under bannerView. 然后创建伪造的NavigationBar(UIView的子类)并将其放置在bannerView下。 In this case you need to add custom button and push and pop inside it's action.
在这种情况下,您需要添加自定义按钮,并在其操作内部按下并弹出。
[self.navigationController setToolbarHidden:NO];
bannerAdmob = [[GADBannerView alloc]init];
[bannerAdmob setDelegate:self];
[bannerAdmob setFrame:adFrame];
bannerAdmob.adUnitID =@"ca-app-pub-0243484158988577/5535857795";
bannerAdmob.rootViewController = self;//self.viewController;
[self.navigationController.view addSubview:bannerAdmob];
self.navigationController.view addSubview:bannerAdmob self.navigationController.view addSubview:bannerAdmob
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.