I would like that my uiwebview change gif image when orientation changes so initially i'm using the following code to load the first image :
NSString * url = @"gif image url...";
int width = width of image;
int height = height of image;
NSString * htmlCode = [NSString stringWithFormat:@"<html><head><body leftmargin=\"0\" topmargin=\"0\"><img id=\"gifimg\" src=\"%@\" width=\"%i\" height=\"%i\"></body></html>", url, width,height];
[tmpWebView loadHTMLString:htmlCode baseURL:nil];
and i put the following code in orientationChanged function:
NSString url = @"portrait image url...";
int width = width of portrait image;
int height = height of portrait image;
if (deviceOrientation == UIInterfaceOrientationLandscapeLeft) {
url = @"landscape image url...";
width = width of landscape image;
height = height of landscape image;
}
NSString * jsString = [[NSString alloc] initWithFormat:@"document.getElementsByTagName('img')[0].style.width= '%dpx';document.getElementsByTagName('img')[0].style.height= '%dpx';document.getElementsByTagName('img')[0].src= '%@'", width,height, url];
[webview stringByEvaluatingJavaScriptFromString:jsString];
[jsString release];
[webview setBackgroundColor:[UIColor clearColor]];
[webview setOpaque:NO];
So the image work fine at first display and when i rotate the device, the (landscape or portrait) the image appear but a part of it was truncated.(after each rotation a part of image is ignored.....), any idea?
Thanks for help