【问题标题】:How to integrate Pinterest in ios application如何将 Pinterest 集成到 ios 应用程序中
【发布时间】:2013-06-09 16:08:07
【问题描述】:

我想在我的应用程序中集成 pinterest。我想在我的应用程序中添加 pinterest 按钮,通过它我可以在 pinterest 上上传图片我推荐 their Developers site 但它对我没有帮助。

我包含 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"];
    }

如有任何帮助,我们将不胜感激。

提前致谢。

【问题讨论】:

    标签: iphone ios objective-c ipad pinterest


    【解决方案1】:

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

    步骤:1here注册一个客户ID

    步骤 : 2here 下载 SDK 并拖放到您的项目中。

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

    Example if your client id is 18571937652947:
    pin18571937652947 is the URL Scheme you need to support.
    

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

     #import <Pinterest/Pinterest.h>
    

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

     Pinterest *pinterest
    

    步骤:5初始化 Pinterest 对象

     pinterest = [[Pinterest alloc]initWithClientId:@"your app client id"]
    

    步骤 : 6 要在视图中使用标准 PinIt 按钮,请按如下方式添加:

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

    步骤 : 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"];
    }
    

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

    【讨论】:

    • Pinterest 网站上的类似指南也可以在这里找到:developers.pinterest.com/ios
    • 是的,但是文档中缺少一些要点。就像 pinterest 对象的初始化一样。
    • @pratikbhiyani 我们可以在浏览器中将应用重定向到 pinterest 网站而不是 pinterest 应用吗?
    • @pratikbhiyani,所以,我无法通过我的应用分享,只能通过 pinterest 应用帮助?哦...
    • @pratikbhiyani 应用程序 pin18571937652947 上的位置是您需要支持的 URL 方案。我是新手,请帮忙。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-21
    • 2015-10-26
    • 1970-01-01
    • 1970-01-01
    • 2017-06-01
    相关资源
    最近更新 更多