2013-03-21 58 views
3

所以我基本上得到了NSDataUIImage,我用UIWebView來顯示它。我這樣做的:在UIWebView中載入UIImage格式的NSData,並居中它

[self.view addSubview:webView]; 

webView.delegate = self; 
webView.scalesPageToFit = YES; 
webView.backgroundColor = [UIColor darkGrayColor]; 

然後我的圖片加載到這樣的:

NSData *image02Data = attachmentToLoad.attachment_data; 
[webView loadData:image02Data MIMEType:@"image/jpg" textEncodingName:nil baseURL:nil]; 

而我得到的結果是不正是我想要的:

enter image description here

正如您所看到的圖像在UIWebView的底部留下白底。我怎樣才能使UIWebView的大小與圖像的大小相等?

回答

1

你見過這篇文章嗎? Click me

我認爲這正是你想要

+0

真棒,謝謝! – 2013-03-21 10:16:01