无法单击添加到Phonegap应用程序的iAd横幅,并略有偏移



所以我大致按照本教程介绍如何使iAd横幅不覆盖Phonegap应用程序,但不得不即兴创作,因为它并没有真正起作用。 因此,在我的mainViewController方法webViewDidFinishLoad中,这是我所拥有的:

- (void)webViewDidFinishLoad:(UIWebView*)theWebView
{
    adView.frame = CGRectOffset(adView.frame, 0, [[UIScreen mainScreen] bounds].size.height - 70);    
    adView.delegate = self;
    [adView setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin];
    [theWebView addSubview:adView];
    [self.view bringSubviewToFront:adView];
    return [ super webViewDidFinishLoad:theWebView ];
}

adView已正确初始化并正常运行。 破坏这一点(如我无法单击横幅)的是 viewWillAppear 中的这段代码:

- (void)viewWillAppear:(BOOL)animated
{
    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7)
    {
        CGRect viewBounds = [self.webView bounds];
        viewBounds.origin.y = 20;
        viewBounds.size.height = viewBounds.size.height - 70;
        self.webView.frame = viewBounds;
    }
    [super viewWillAppear:animated];
}

我添加了 70px 偏移量,以使横幅不覆盖内容。 现在,如果我删除此代码,我可以很好地单击横幅。 怎么了?

愚蠢的我。 我将子视图添加到theWebView而不是self.view,这使得它超出了其边界并且无法单击。

最新更新