tags:

views:

46

answers:

2

Hi, Experts

i want to change image periodically in UIImageView in my Application.

and image will come from web.

can i run javaScript enable page in UIWebView ?

is it possible to do ? or any other way to implement this ?

any code snippet if awailable...

waiting for you reply...

thanks in advance.

+1  A: 

Edit: Oh, sorry, I missed that you wanted to place the image in a UIImageView. Andiihs answer will guide you better than mine. I will keep my answer for anyone stumbling into this looking for how to run JavaScript.

Just use stringByEvaluatingJavaScriptFromString: and you have executed the JavaScript on the loaded page in your UIWebView. This scripts reads the page title and places it in the "pageTitle" variable.

NSString *pageTitle = [myWebView stringByEvaluatingJavaScriptFromString:@"document.title"];

You can also perform any methods etc...

[myWebView stringByEvaluatingJavaScriptFromString:@"doSomething('Hello!'); doSomethingElse('And again...');"];
alleus
+1  A: 

I think JavaScript is the wrong approach. (You start off talking about a UIImageView - I guess that is where you want your image?) Use an NSTimer to update your image. You can easily fetch an image from a URL

http://blogs.oreilly.com/digitalmedia/2008/02/creating-an-uiimage-from-a-url.html

Andiih