2011-11-30 18 views
1

我有一個橫幅,需要在標籤欄控制器內的標籤欄下方顯示。讓它顯示並不是最難的部分,我已經解決了這個問題,但是看起來不知怎麼的,我正在使用的方法似乎把它放在了正常的輸入區域之外。在UITabBar下面獲取輸入

基本上,我使用這個橫幅作爲廣告,但我不希望它覆蓋標籤欄。

下面是我使用創建的標籤欄下方的橫幅代碼:

const float footerHeight = 34.5; 
    const float statusBarHeight = 20.f; 
    const float viewHeight = 480 - statusBarHeight - bannerHeight - footerHeight; 
    const float viewY = 0 + statusBarHeight + bannerHeight; 

    UIView *footerView = [[UIView alloc] initWithFrame:CGRectMake(0, viewHeight, 320, footerHeight)]; 
    [footerView setContentMode:UIViewContentModeScaleToFill]; 
    [footerView addSubview:footerButton]; 

    [self.tabBarController.view addSubview:footerView]; 
    [footerView release]; 

    self.tabBarController.view.frame = CGRectMake(0, viewY, 320, viewHeight); 

只是在一些變量的引用也有上面的視圖頂部的標題爲好。 footerButton是我創建並連接IB的UIButton。

回答

1

我最終設法把根UIWindow對象上的UITapGestureRecognizer,然後手工做RECT cheecks,看它是否是內部正常,tabBarController較小的範圍,以解決此問題並轉發輸入到我的頁腳欄否則

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch 
{ 
    CGPoint touchPoint = [touch locationInView:self.window]; 
    if (touchPoint.y > 57 && touchPoint.y < 446) 
    { 
     return NO; 
    } 
    return YES; 
} 

-(IBAction) handleTap:(UIGestureRecognizer*)sender 
{ 
    if (sender.state == UIGestureRecognizerStateEnded) 
    { 
     //handle 
     CGPoint tapPoint = [sender locationOfTouch:0 inView:self.window]; 
     if (tapPoint.y >= 446) 
     { 
      [footerButton clickedAd]; 
     } 
     NSLog(@"(%f,%f)", tapPoint.x, tapPoint.y); 
    } 
}