我想,当方向改变所以最初 我使用下面的代码我UIWebView的变化gif图片加载第一图像:UIWebView的变化图像时方向改变
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];
,我把下面的代码在orientationChanged功能:
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];
因此,在第一显示图像的工作细,当我旋转设备中,(横向或纵向)上的图像出现,但它的一部分被截断(后每转动一圈的一部分。图像被忽略.....),a你有想法吗?
感谢您的帮助
感谢您的回答,我已经尝试过,但willAnimateRotationToInterfaceOrientation从来没有被称为 – Sultana
@Sultana这就是事情,我已经在上面告诉我的答案,在这种情况下,你如何设置图像。这意味着你必须照顾方向也在这里这是在iOS6中管理方向的链接..,我认为你的应用程序运行在iOS6上... http://stackoverflow.com/questions/12577879/shouldautorotatetointerfaceorientation-is-not-working-in-ios-6/12581799 #12581799 – Kamarshad
我的方向工作正常,因为我测试了一个uimageview中的jpeg图像和视图没有任何问题旋转,但是当我想在uiwebview中显示一个gif时, – Sultana