Javascript IOS中的电话间隔高度变化?

Javascript IOS中的电话间隔高度变化?,javascript,html,ios,objective-c,cordova,Javascript,Html,Ios,Objective C,Cordova,我有一个简单的phonegap项目,我想在其中添加admob,我需要规定phonegap的高度,在屏幕顶部留一个50dp的空间,在ipad上留一个90dp的空间,我不确定怎么做,现在我只是在html文件中留了一个50dp的空间,我把admob放在html上方的屏幕顶部,如果我想在iPhone和iPad上使用智能横幅,我肯定这不是正确的方式 我正在尝试用这段代码做一些更改,但运气不好,我确信还有另一种方法 CGRect screenBounds = [[UIScreen mainScreen] b

我有一个简单的phonegap项目,我想在其中添加admob,我需要规定phonegap的高度,在屏幕顶部留一个50dp的空间,在ipad上留一个90dp的空间,我不确定怎么做,现在我只是在html文件中留了一个50dp的空间,我把admob放在html上方的屏幕顶部,如果我想在iPhone和iPad上使用智能横幅,我肯定这不是正确的方式

我正在尝试用这段代码做一些更改,但运气不好,我确信还有另一种方法

CGRect screenBounds = [[UIScreen mainScreen] bounds];

self.window = [[[UIWindow alloc] initWithFrame:screenBounds] autorelease];

您必须获取并更新webView框架。下面类似的内容也支持屏幕旋转:

// detect orientation 
UIDeviceOrientation currentOrientation = [[UIDevice currentDevice] orientation];
BOOL isLandScape = (UIInterfaceOrientationIsLandscape(currentOrientation));

CGRect webViewFrame = webView.frame;
CGRect superViewFrame = webView.superview.frame;
CGRect bannerViewFrame = bannerView.frame;

// Frame of the main Cordova webview and its max size
CGFloat webViewHeight = superViewFrame.size.height;

// define height for banner, 0 if hidden
CGFloat bannerHeight = bannerViewFrame.size.height;

if (bannerView.hidden){
  bannerHeight = 0.0;
}

// set different size for landscape
if (isLandScape) {
  webViewHeight = superViewFrame.size.width;
}

webViewHeight -= bannerHeight;
webViewFrame.size.height = webViewHeight;

// move webview x location
webViewFrame.origin.x = bannerHeight;

// finally set the frame
webView.frame = webViewFrame;