iPhone-如何发送图像+;使用ShareKit向Facebook发送文本?
根据我应用程序中的要求,我想向Facebook发送图像和文本(动态;由用户编写)。我已经编写了发送图像的代码,如下所示:iPhone-如何发送图像+;使用ShareKit向Facebook发送文本?,iphone,objective-c,xcode,facebook,Iphone,Objective C,Xcode,Facebook,根据我应用程序中的要求,我想向Facebook发送图像和文本(动态;由用户编写)。我已经编写了发送图像的代码,如下所示: NSString *str = [NSString stringWithFormat:@"00%d",currentIndex_+1]; NSString *imageIndex = [[NSBundle mainBundle] pathForResource:str ofType:@"png"]; NSLog(@"image index:%@",imageIndex); /
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 imageWithContentsOfFile:imageIndex] title:@"sent via iphone"];
[NSClassFromString(@"SHKFacebook") performSelector:@selector(shareItem:) withObject:item];
但是现在我还想用这个图像发送文本(动态)。如何发送带有图像的文本?非常简单。只需确保导入SHKItem和SHKFaceBook即可
UIImage *image = [UIImage imageNamed:@"someImage.png"];
SHKItem *itemToShare = [SHKItem image:image title:@"Some title if you want to"];
[SHKFacebook shareItem:itemToShare];
将此代码替换为SHKFacebook.m中的dialog.attachment,并替换我用粗体书写的图像url/路径
并使用以下代码发布您的文本:
SHKItem *item1 =[SHKItem text:@"hello"];<p>
[SHKFacebook shareItem:item1];
SHKItem*item1=[SHKItem text:@“hello”]
[SHKFacebook shareItem:item1];
为什么不使用NSString stringWithFormat:即`NSString*var=@“aaa”;SHKItem*item=[SHKItem image:[UIImage imageWithContentsOfFile:imageIndex]标题:[NSString stringWithFormat:@“%@\n%@”,var,@“通过iSLP Break Roomi iPhone应用程序发送”]`但这将是静态文本,我想发送用户编写的文本您可以在我的示例中输入用户在NSString*var中编写的文本,但我想发送动态(用户编写)文本,而不是静态文本
SHKItem *item1 =[SHKItem text:@"hello"];<p>
[SHKFacebook shareItem:item1];