2011-07-12 29 views
0

這裏是我使用的代碼:關於在UIWebview中嵌入UIImage的問題;你如何擺脫邊界?

NSString *imagePath = [[NSBundle mainBundle] resourcePath]; 
imagePath = [imagePath stringByReplacingOccurrencesOfString:@"/" withString:@"//"]; 
imagePath = [imagePath stringByReplacingOccurrencesOfString:@" " withString:@"%20"]; 

NSString *HTMLData = @"<meta name=\"viewport\" content=\"width=320\"/> <img src=\"image.png\" alt=\"\" width=\"320\" height=\"480\">"; 
[self.webView loadHTMLString:HTMLData baseURL:[NSURL URLWithString: [NSString stringWithFormat:@"file:/%@//",imagePath]]]; 
[self.webView setScalesPageToFit:YES]; 

有周圍的Web視圖圖像白色邊框。有沒有什麼辦法讓圖像佔據屏幕?

編輯:新增截圖

The white border around the image is the problem

在此先感謝您的幫助。

+0

可以發表它的截圖嗎? – booleanBoy

回答

3

嘗試增加將CSS margin屬性設置爲0px一個body標籤。生成的HTML應該看起來像這樣:

<meta name="viewport" content="width=320"/> 
<body style="margin:0px;"> 
...img tag goes here... 
</body> 
1

讓您嘗試添加邊框= 「0」

變化:<img src=\"image.png\" alt=\"\" width=\"320\" height=\"480\">

要:<img src=\"image.png\" alt=\"\" width=\"320\" height=\"480\ border=\"0\">

+0

是的,不幸的是問題仍然存在。 – jleibsly2002

+0

似乎有一些額外的保證金/填充在那裏。讓'style =「margin:0; padding:0」'' –

+0

加上'body'標籤謝謝,修正了它。 – jleibsly2002