开发者

Passing a UISlider value into stringByEvaluatingJavaScriptFromString?

I have a UISlider and I'm trying to pass its value into a window.scrollBy string. Basically, I'm attempting user-configurable auto-scrolling of web content.

The actual scrolling is working, but I'm unable to pass a value into the JavaScript by using the normal %f and , method.

[_webView stringByEvaluatingJavaScriptFromString:@"window.scrollBy(0,5);"];

I'm using the above, and I'd like the '5' to be substituted with the value of the slider.

Can this be done without the need for more Java 开发者_C百科(I'm absolutely not a JavaScript programmer!)


First you have to build your javascript code using StringWithFormat:

NSString *string = [NSString stringWithFormat:@"window.scrollBy(0,%f);", slider.value];
[_webView stringByEvaluatingJavaScriptFromString:string];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜