我會打破什麼終於解決了這對我來說。
我不得不換我這個內容。
<html><head><meta name=\"viewport\" content=\"initial-scale=1, user-scalable=no, width=device-width\" /></head><body>%@</body></html>
實現以下觀點做負載。
-(void)webViewDidFinishLoad:(UIWebView *)webView {
[self layoutSubviews];
webView.scrollView.scrollEnabled = NO; // Property available in iOS 5.0 and later
CGRect frame = webView.frame;
frame.size.height = 1; // Set the height to a small one.
webView.frame = frame; // Set webView's Frame, forcing the Layout of its embedded scrollView with current Frame's constraints (Width set above).
frame.size.height = webView.scrollView.contentSize.height; // Get the corresponding height from the webView's embedded scrollView.
webView.frame = frame;
}
and
-(void) layoutSubviews {
[super layoutSubviews];
[body stringByEvaluatingJavaScriptFromString:
[NSString stringWithFormat:
@"document.querySelector('meta[name=viewport]').setAttribute('content', 'width=%d;', false); ",
(int)body.frame.size.width]];
}
,最後我的webview做所有正確的事情來擴展自己的內容。
document.body.offsetHeight – Srikanth
在這裏問了一個類似的問題「http://stackoverflow.com/questions/2979854/uiwebview-get-total-height-of-contents-using-javascript」 – Srikanth