2012-04-05 92 views
0

我在我的ViewController中设置了AdMob,它位于底部。一切都很好,直到我隐藏我的导航栏。当我的导航栏被隐藏时,AdMob框架会上升。我怎样才能让它坚守我的看法?这是我的东西位置AdMob隐藏导航栏时底部

-(void)navBarTransition:(BOOL)hide 
    { 
     [[self navigationController] setNavigationBarHidden:hide animated:YES]; 

     //addjust frame height when ads is visible 
     if(hide) 
     { 
     CGRect frame = CGRectMake(0.0,self.view.frame.size.height + GAD_SIZE_320x50.height,GAD_SIZE_320x50.width, GAD_SIZE_320x50.height); 

     [bannerView_ setFrame:frame]; 
     } 
    } 
+0

检查帧的Y协调员 – Hiren 2012-04-05 06:44:30

+0

的CGRect帧= CGRectMake(0.0 ,self.view.frame.size.height - GbannerView.frame.size.height,GAD_SIZE_320x50.width,GAD_SIZE_320x50.height); – priyanka 2012-04-05 06:46:04

+0

@ CocoaMatters问题。我将geting 0作为bannerView_的Y点。 @ priyanka。我之前尝试过,但它也没有工作。 bannerView仍然不会坚持到底部。 – Diffy 2012-04-05 06:56:37

回答

0

在隐藏导航栏之前,将origin.y向下移动它的高度。还要确保您没有自动调整遮罩(灵活的顶部/底部边距?)干扰您的定位。

CGRect bFrame = bannerView_.frame; 
CGFloat newY = bFrame.origin.y + self.navigationController.navigationBar.frame.size.height; 
bFrame.origin.y = newY; 
[bannerView_ setFrame:bFrame]; 

如果这不起作用,你可以尝试使用CJPAdController披露:我写了这个类)。如果您实现这个类,你可以简单地调整你的代码下面的(刚刚测试,它似乎工作,你会它想):

[[self navigationController] setNavigationBarHidden:hide animated:YES]; 
if(hide) 
    [CJPAdController sharedManager] fixAdViewAfterRotation];