我試圖在UIWebView.F中顯示圖像,但我不知道爲什麼我的圖像未顯示在UIWebVeiw中。這是我的代碼。如何在webview中顯示圖像?
-(void)pInterest
{
UIImage *myImage;
myImage=imgView.image;
WebViewController *webViewController = [[WebViewController alloc] initWithNibName:@"WebViewController" bundle:nil];
webViewController.mypimage = myImage;
[[[[UIApplication sharedApplication] keyWindow] rootViewController] presentModalViewController:webViewController animated:YES];
}
現在通過圖像WebViewController我WebViewController代碼後,
- (void)viewDidLoad
{
NSData* data = UIImageJPEGRepresentation(mypimage, 1.0f);
[Base64 initialize];
NSString *strEncoded = [Base64 encode:data];
NSMutableString *htmlString = [[NSMutableString alloc] initWithCapacity:1000];
[htmlString appendFormat:@"<html> <body>"];
[htmlString appendFormat:@"<p align=\"center\"><a href=%@ class=\"pin-it-button\" count-layout=\"horizontal\"><img border=\"0\" src=\"http://assets.pinterest.com/images/PinExt.png\" title=\"Pin It\" /></a></p>", buttonUrl];
[htmlString appendFormat:@"<p align=\"center\"><img width=\"400px\" height = \"400px\" src=%@></img></p>", imageUrl];
[htmlString appendFormat:@"<script type=\"text/javascript\" src=\"//assets.pinterest.com/js/pinit.js\"></script>"];
[htmlString appendFormat:@"</body> </html>"];
[mywebview setBackgroundColor:[UIColor clearColor]];
NSString *path = [[NSBundle mainBundle] bundlePath];
NSURL *baseURL = [NSURL fileURLWithPath:path];
[mywebview loadHTMLString:htmlString baseURL:baseURL];
[mywebview setOpaque:NO];
}
,當我使用此代碼顯示它下面的結果嘗試。
任何幫助將是appriated.Thanks
你想實現pinteres在你的項目中? –
是@Sudha我想在pinterest上發佈圖片。 – jamil