1

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 (I'm absolutely not a JavaScript programmer!)

Luke
  • 9,512
  • 15
  • 82
  • 146

1 Answers1

1

First you have to build your javascript code using StringWithFormat:

NSString *string = [NSString stringWithFormat:@"window.scrollBy(0,%f);", slider.value];
[_webView stringByEvaluatingJavaScriptFromString:string];
Youssef
  • 3,582
  • 1
  • 21
  • 28