图片不会出现在Facebook上

时间:2011-12-01 13:07:39

标签: iphone objective-c xcode

我已经编写了一些使用Sharekit在Facebook上分享图像的代码。代码如下:

NSString *str = [NSString stringWithFormat:@"00%d",currentIndex_+1];        
NSString *imageIndex = [[NSBundle mainBundle] pathForResource:str ofType:@"png"];
NSLog(@"image index:%@",imageIndex);
// NSData *myData = [[NSData alloc] initWithContentsOfFile:imageIndex];

SHKItem *item = [SHKItem image:[UIImage imageNamed:imageIndex] title:@"Sent via Card Application iPhone App"];
[NSClassFromString(@"SHKFacebook") performSelector:@selector(shareItem:) withObject:item];

显示错误消息“必需的上传文件”。

如何解决此问题?

1 个答案:

答案 0 :(得分:1)

以下内容可能有所帮助:

NSString *imageIndex = [[NSBundle mainBundle] pathForResource:str ofType:@"png"];

将返回图像的路径。

[UIImage imageNamed:imageIndex]

通过名称从应用程序包中获取图像。 您在此处传递路径和名称,因此无法找到图像。

试试这个:

SHKItem *item = [SHKItem image:[UIImage imageNamed:str] title:@"Sent via Card Application iPhone App"];
[NSClassFromString(@"SHKFacebook") performSelector:@selector(shareItem:) withObject:item];