将图像从本地捆绑发布到Pinterest iphone。

时间:2013-09-05 18:08:05

标签: ios iphone objective-c post uiimage

我使用以下代码通过网络视图实现了PinInterest:

NSString *description = @"Post your description here";
NSURL* sUrl = [NSString stringWithFormat:@"http://4.bp.blogspot.com/-w4oTZjlpgwo/T5_pi-KJPuI/AAAAAAAAAoM/rKm3E0XCbgY/s1600/red_rose_flower3.jpg"];// pass your link here with your image name

// NSLog(@"URL:%@", sUrl);
NSString *protectedUrl = ( NSString *)CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(NULL,( CFStringRef)sUrl, NULL, (CFStringRef)@"!*'\"();:@&=+$,/?%#[]% ",CFStringConvertNSStringEncodingToEncoding(NSUTF8StringEncoding)));
NSLog(@"Protected URL:%@", protectedUrl);
NSString *imageUrl = [NSString stringWithFormat:@"\"%@\"", sUrl];

imageUrl=[[NSBundle mainBundle]pathForResource:mAppDelegate.imagename ofType:nil];

NSString *buttonUrl = [NSString stringWithFormat:@"\"http://pinterest.com/pin/create/button/?url=www.flor.com&media=%@&description=%@\"", protectedUrl, description];

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=\"300px\" height = \"400px\" src=%@></img></p>", imageUrl];
[htmlString appendFormat:@"<script type=\"text/javascript\" src=\"//assets.pinterest.com/js/pinit.js\"></script>"];
[htmlString appendFormat:@"</body> </html>"];
return htmlString;

我也尝试使用PinInterest iOS SDK,但我发现只能将图片固定在网址上。

我需要从本地捆绑图像中固定图像。任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:1)

阅读文档一次,他们说现在,“我们只支持从网址固定图像。将来,我们将添加对固定本地图像的支持。”我认为这回答了你的问题。更多澄清芦苇this。希望这会有所帮助:)