HTML5   发布时间:2022-04-27  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了iOS Pin It SDK,没有文档和示例代码大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试通过 Pinterest’s website.的基础教程

下载文档和iOS sdk的链接不提供文档或示例代码.其中只有捆绑包

这是我的viewcontroller.m文件

#import "ViewController.h"
#import <Pinterest/Pinterest.h>

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view,typically from a nib.
    UIButton* pinItButton = [Pinterest pinItButton];
    [pinItButton addTarget:self
                    action:@SELEctor(pinIt:)
          forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:pinItButton];

}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)pinIt:(id)sender
{
    Pinterest *pinterest = [[Pinterest alloc]initWithClientId:@"1431885" urlscheR_684_11845@eSuffix:@"pin1431885"];
    [pinterest createPinWithImageURL:@"http://www.warrenphotographic.co.uk/photography/bigs/10122-Silver-and-red-kittens-white-BACkground.jpg" sourceURL:@"http://placekitten.com" description:@"Pinning from Pin It Demo"];
}

@end

我的代码相当直接,我无法让它在我的开发iPhone上运行
它一直在扔:

2013-06-06 17:17:27.787 Pinterest TesTing[9403:907] -[__NSCFConstantString absoluteString]: unrecognized SELEctor sent to instance 0x1c86c
2013-06-06 17:17:31.626 Pinterest TesTing[9403:907] *** TerminaTing app due to uncaught exception 'NSInvalidArgumentexception',reason: '-[__NSCFConstantString absoluteString]: unrecognized SELEctor sent to instance 0x1c86c'
*** First throw call stack:
(0x32f4d3e7 0x3ac48963 0x32f50f31 0x32f4f64d 0x32ea7208 0x1a9f9 0x1a71d 0x34e47087 0x34e4703b 0x34e47015 0x34e468cb 0x34e46db9 0x34d6f5f9 0x34d5c8e1 0x34d5c1ef 0x36a745f7 0x36a74227 0x32f223e7 0x32f2238b 0x32f2120f 0x32e9423d 0x32e940c9 0x36a7333b 0x34db02b9 0x19f4d 0x3b075b20)
libc++abi.dylib: terminate called throwing an exception

解决方法

将uRL作为NSString对象发送. NSString没有-absoluteString方法,这就是崩溃日志告诉你的.

Pinterest方法的声明(在Pinterest.h中)如下:

- (void)createPinWithImageURL:(NSURL *)imageURL
                    sourceURL:(NSURL *)sourceURL
                  description:(NSString *)descriptiontext;

您需要为imageURL和sourceURL发送NSURL对象,而不是NSString.

所以对于你的情况:

- (void)pinIt:(id)sender
{
    NSURL *imageURL     = [NSURL URLWithString:@"http://www.warrenphotographic.co.uk/photography/bigs/10122-Silver-and-red-kittens-white-BACkground.jpg"];
    NSURL *sourceURL    = [NSURL URLWithString:@"http://placekitten.com"];

    Pinterest *pinterest = [[Pinterest alloc]initWithClientId:@"1431885" urlscheR_684_11845@eSuffix:@"pin1431885"];
    [pinterest createPinWithImageURL:imageURL
                           sourceURL:sourceURL
                         description:@"Pinning from Pin It Demo"];
}

大佬总结

以上是大佬教程为你收集整理的iOS Pin It SDK,没有文档和示例代码全部内容,希望文章能够帮你解决iOS Pin It SDK,没有文档和示例代码所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。