我已经编写了一些使用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];
显示错误消息“必需的上传文件”。
如何解决此问题?
答案 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];