0

私はこの小さなコードを持っています:

NSString *size = [LabelNewContent stringByEvaluatingJavaScriptFromString:@"return     Math.max(
document.body.scrollHeight, document.documentElement.scrollHeight,
document.body.offsetHeight, document.documentElement.offsetHeight,
document.body.clientHeight, document.documentElement.clientHeight
);"];

問題は、xcode が括弧とコンマを文字列全体として認識しないことです。

4

3 に答える 3

8

\複数行の文字列にするために使用します

NSString *size = [LabelNewContent stringByEvaluatingJavaScriptFromString:@"return     Math.max(\
document.body.scrollHeight, document.documentElement.scrollHeight,\
document.body.offsetHeight, document.documentElement.offsetHeight,\
document.body.clientHeight, document.documentElement.clientHeight\
);"];
于 2013-08-26T11:15:34.887 に答える
0
NSString *size = [LabelNewContent stringByEvaluatingJavaScriptFromString:@"return     Math.max/(document.body.scrollHeight, document.documentElement.scrollHeight,document.body.offsetHeight, document.documentElement.offsetHeight,   document.body.clientHeight, document.documentElement.clientHeight);"];

上記のことを試してください

于 2013-08-26T11:17:05.213 に答える
-2

コードを次のように置き換えます

NSString *size = [LabelNewContent stringByEvaluatingJavaScriptFromString:@"return %f",Math.max(
                      document.body.scrollHeight, document.documentElement.scrollHeight,
                      document.body.offsetHeight, document.documentElement.offsetHeight,
                      document.body.clientHeight, document.documentElement.clientHeight
                      )];

それがあなたを助けることを願っています。

于 2013-08-26T11:19:25.950 に答える