2013-07-26 125 views
1

我正在一个IOS应用程序是这样的结构:AdMob的横幅位置

主导航(对于mainapp登录导航控制器) - > tabBarController(3选项卡栏项) - > NavigationController(导航contronoller为每个标签栏项目)。

我想添加admob在我的应用程序的顶部(在我的导航栏的顶部...)。 在我的标签栏项目的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]]; 

} 

旗帜,隐藏导航栏,就像这样: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)]; 

但用途:

bannerView_ = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner]; 

如此看来:http://cl.ly/image/203v1C2W1b2P 相反我想,横幅显示在顶部,所有内容(也是导航栏)...去横幅下面。 我该怎么办? 谢谢,对不起我的英文不好。

回答

0

NavigationBar必须位于顶部,不能更改位置。

隐藏默认的导航栏

[self.navigationController setNavigationBarHidden:YES]; 

然后创建伪造的导航栏(UIView的子类),并把它bannerView下。在这种情况下,您需要添加自定义按钮并在其动作中进行推送和弹出。

+0

没有其他soluton或解决方法吗?例如我有应用程序委托中的mainNavigation,这是隐藏的......也许我可以使用它? –

+0

我尝试过: 'code' AppDelegate * appDelegate =(AppDelegate *)[[UIApplication sharedApplication] delegate]; appDelegate.mainNavController.navigationBarHidden = NO; [appDelegate.mainNavController.view addSubview:bannerView_]; –

+0

它看起来是这样的:http://cl.ly/image/2g2R28242Q2w –

0
[self.navigationController setToolbarHidden:NO]; 
    bannerAdmob = [[GADBannerView alloc]init]; 
    [bannerAdmob setDelegate:self]; 

    [bannerAdmob setFrame:adFrame]; 
    bannerAdmob.adUnitID [email protected]"ca-app-pub-0243484158988577/5535857795"; 

    bannerAdmob.rootViewController = self;//self.viewController; 
    [self.navigationController.view addSubview:bannerAdmob]; 

self.navigationController.view addSubview:bannerAdmob