我有这个小代码:
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不能将括号和逗号识别为整个字符串。
答案 0 :(得分: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\
);"];
答案 1 :(得分: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);"];
尝试上面的事情
答案 2 :(得分:-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
)];
希望它会对你有所帮助。