根据分辨率重新定义webView尺寸

在应用中采用storyboard。不知道怎么根据屏幕分辨率对webView进行尺寸调整。

CSDN移动问答
我希望标题在两个分辨率下尺寸相同,但是webview 的高度根据分辨率调整。

不能用自动布局,因为要在ios5以上版本用。
谢谢。

实现根据屏幕调整Webview框架,可在分配webView处使用下面方法。

CGRect webFrame = [[UIScreen mainScreen] applicationFrame];
webFrame.origin.y -= 20.0; // statusbar 20 px cut from y of frame
webView = [[UIWebView alloc] initWithFrame:webFrame];
webView.scalesPageToFit = YES;
webView.autoresizesSubviews = YES;
webView.autoresizingMask=(UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth);
[webView setBackgroundColor:[UIColor clearColor]];

判断是否为iphone5的宏定义

#define iphone5 [UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 1136),[[UIScreen mainScreen] currentMode].size) : NO;

通过判断是否为iphone5,如果为iphone5 则当前视图的height增加 88