所以我粗略地关注了如何使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偏移量,以使横幅不覆盖内容。现在,如果我删除此代码,我可以点击横幅罚款。有什么问题?
答案 0 :(得分:0)
theWebView
而不是self.view
,这使得它超出了边界并且无法点击。