从url UIWEBVIEW +iphone加载图像

时间:2023-01-24 16:16:30

I am trying to display the image in UIWebView and added uiwebiview into the uiscrollview as i wanna give the page controller effect:-

我试图在UIWebView中显示图像并将uiwebiview添加到uiscrollview中,因为我想给页面控制器效果:-

UIWebView *webview_obj=[[UIWebView alloc] initWithFrame:CGRectMake(xcorrd,0,200,320)];
NSString *html = [NSString stringWithFormat:@"<html><body><img src='%@' width='100%' height='100%'></body></html>",imageStr];
[webview_obj loadHTMLString:html baseURL:nil];
webview_obj.scalesPageToFit=YES;
[scroll_views addSubview:webview_obj];

My problem is :- When i try to load the image of sizd 200X320. the image come in perfect size.but some white portion(approximate 30-40pixel) will added on the bottom and side of the webview. and automatically the content size get increase and give the scroll.

我的问题是:-当我试图加载sizd 200X320的图像时。这张照片的大小恰到好处。但是一些白色部分(大约30-40像素)将添加到webview的底部和侧边。内容大小自动增加,并给出滚动条。

I am uploading the screenshot for the output i am getting:-

我正在上传我得到的输出的屏幕截图:-。

从url UIWEBVIEW +iphone加载图像

Black potion in the webview part.and white is somehting which get automatically added to the image.. the size of the image i am using is :- 200 :- with and 320 :- height Thanks & Regards shweta

在webview部分的黑色药水。而白色是一些自动添加到图像中的东西。我使用的图片的尺寸是:- 200:-和320:-高度谢谢和问候shweta

1 个解决方案

#1


3  

Added CSS STYLE in the HEAD tag..

在HEAD标签中添加了CSS样式

NSString *html = [NSString stringWithFormat:@"<html><head><style>body{padding:0; margin:0;}</style></head><body><img src='%@' width='100%' height='100%'></body></html>",imageStr];

#1


3  

Added CSS STYLE in the HEAD tag..

在HEAD标签中添加了CSS样式

NSString *html = [NSString stringWithFormat:@"<html><head><style>body{padding:0; margin:0;}</style></head><body><img src='%@' width='100%' height='100%'></body></html>",imageStr];