如何在ios应用程序中集成Pinterest

nis*_*kar 14 iphone objective-c ipad ios pinterest

我想在我的应用程序中集成pinterest.我想在我的应用程序中添加pinterest按钮,通过它我可以在pinterest上传图像我推荐他们的开发者网站,但它并没有帮助我.

我包含SDK并尝试了他们的代码,但它对我不起作用.

  #import <Pinterest/Pinterest.h>

UIButton* pinItButton = [Pinterest pinItButton];
    [pinItButton addTarget:self
                    action:@selector(pinIt:)
          forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:pinItButton];

 - (void)pinIt:(id)sender
    {
        [_pinterest createPinWithImageURL:@"http://placekitten.com/500/400"
                                sourceURL:@"http://placekitten.com"
                              description:@"Pinning from Pin It Demo"];
    }
Run Code Online (Sandbox Code Playgroud)

请任何帮助将不胜感激.

提前致谢.

pra*_*ani 30

我不明白你的实际问题是什么,但在这里我提供了一些简单的步骤来将pinterest集成到你的应用程序

步骤:1此处注册客户端ID

步骤:2此处下载SDK 并拖放到您的项目中.

步骤:3然后,您需要添加URL类型以支持从Pinterest应用程序打开您的应用程序,因此将URL类型添加到plist文件

Example if your client id is 18571937652947:
pin18571937652947 is the URL Scheme you need to support.
Run Code Online (Sandbox Code Playgroud)

步骤:4要使用Pinterest框架,您需要将其导入到您的文件中.

 #import <Pinterest/Pinterest.h>
Run Code Online (Sandbox Code Playgroud)

并在.h文件中声明其对象

 Pinterest *pinterest
Run Code Online (Sandbox Code Playgroud)

步骤:5初始化Pinterest对象

 pinterest = [[Pinterest alloc]initWithClientId:@"your app client id"]
Run Code Online (Sandbox Code Playgroud)

步骤:6要在视图中使用标准PinIt按钮,请将其添加为:

 UIButton* pinItButton = [Pinterest pinItButton];
    [pinItButton addTarget:self
                    action:@selector(pinIt:)
          forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:pinItButton];
Run Code Online (Sandbox Code Playgroud)

步骤:7您将需要处理此操作的示例如下:

- (void)pinIt:(id)sender
{
    NSURL *imageURL     = [NSURL URLWithString:@"http://placekitten.com/500/400"];
    NSURL *sourceURL    = [NSURL URLWithString:@"http://placekitten.com"];


    [pinterest createPinWithImageURL:imageURL
                           sourceURL:sourceURL
                         description:@"Pinning from Pin It Demo"];
}
Run Code Online (Sandbox Code Playgroud)

注意:pinterest应用程序应安装在您的设备中,否则此代码重定向到iTunes下载pinterest应用程序

  • @pratikbhiyani我们可以将应用程序重定向到浏览器中的pinterest网站而不是pinterest应用程序吗? (3认同)
  • 雅但是在doc中有一些缺失.像pinterest对象的初始化. (2认同)
  • +1节省了我很多时间非常感谢 (2认同)