0

I have this small code:

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
);"];

the problem is xcode doesnt recognize the parentheses and commas as a whole string.

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 回答