0

章ごとにepubファイルをwebviewにロードしようとしています。画面の幅が知りたいです。

例えば:

if the content have one and half page text means it returns the width to be as 768
but
if the content have two full page text means it returns the width to be as 1536

私のコードは次のとおりです。

int totalWidth = [[webView stringByEvaluatingJavaScriptFromString:@"document.documentElement.scrollWidth"] intValue];
4

1 に答える 1

0

これを使って

[[webView stringByEvaluatingJavaScriptFromString:@"document.body.scrollWidth"] intValue];

「document.body.scrollWidth」は、UIWebView のコンテンツのサイズを返します。

于 2012-02-22T11:07:08.617 に答える