无法点击添加到具有轻微偏移的Phonegap应用的iAd Banner

时间:2014-01-05 01:05:49

标签: ios cordova iad

所以我粗略地关注了如何使iAd横幅不能覆盖Phonegap应用程序的this教程,但不得不即兴创作,因为它并没有真正起作用。因此,在我webViewDidFinishLoad方法的mainViewController中,我就是这样的:

- (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偏移量,以使横幅不覆盖内容。现在,如果我删除此代码,我可以点击横幅罚款。有什么问题?

1 个答案:

答案 0 :(得分:0)

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