从网址UIWEBVIEW + iphone加载图片

时间:2013-04-19 04:42:30

标签: iphone ios uiwebview uiscrollview uiimageview

我正在尝试在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];

我的问题是: - 当我尝试加载sizd 200X320的图像。图像的大小合适。但是在webview的底部和侧面会添加一些白色部分(大约30-40像素)。 并自动增加内容大小并给出滚动。

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

enter image description here

webview部分中的黑色药水。而白色则会自动添加到图像中。 我使用的图像大小是: - 200: - 和320: - 高度 谢谢&amp;问候 shweta

1 个答案:

答案 0 :(得分:3)

CSS STYLE代码中添加了HEAD

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