开发者

UIWebView resize

My webView is not resizing properly after it finished loading. I have tried this code.

- (void)webViewDidFinishLoad:(UIWebView *)webview {
    CGRect frame = webView.frame;
    frame.size.height = 1;
    frame.size.width = screenWidth;
    webView.frame = frame;
    CGSize fittingSize = [webView sizeThatFits:CGSizeZero];
    frame.size = fittingSi开发者_运维知识库ze;
    webView.frame = frame;
    [bodyScroll setContentSize:CGSizeMake(screenWidth, webView.frame.origin.y + webView.frame.size.height+keyboardRectY+60)];

It is incresing the width beyond the screenWidth and hence my content horizontally expands beyond the view size which I don't want.

changing

CGSize fittingSize = [webView sizeThatFits:CGSizeMake(screenWidht, 1)];

also leads to the same situation.

How can I get rid of this? The webview width should always remain as screenwidth and only it's height should adjust based on the content size so that the webView just about fits the whole content.

Thanks in Advance


Try something like this:

WebView.scalesPageToFit = YES;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜