在facebook上与sharekit共享多个项目

use*_*470 6 iphone facebook ios sharekit

我知道如何分享孤独的形象:

// Create a UIImage.
UIImage *image = [UIImage imageNamed:@"ShareKit.jpg"];

// Wrap the UIImage within the SHKItem class
SHKItem *item = [SHKItem image:image title:@"This image was sent with ShareKit!"];

// Create a ShareKit ActionSheet and Assign the Sheet an SHKItem
SHKActionSheet *actionSheet = [SHKActionSheet actionSheetForItem:item];

// Display the ActionSheet in the current UIView
[actionSheet showInView:self.view];
Run Code Online (Sandbox Code Playgroud)

以及如何分享孤独的链接:

// Create an NSURL. This could come from anywhere in your app.
NSURL *url = [NSURL URLWithString:@"http://mobile.tutsplus.com"];

// Wrap the URL within the SHKItem Class
SHKItem *item = [SHKItem URL:url title:@"Mobiletuts!"];

// Create a ShareKit ActionSheet and Assign the Sheet an SHKItem
SHKActionSheet *actionSheet = [SHKActionSheet actionSheetForItem:item];

// Display the ActionSheet in the current UIView
[actionSheet showInView:self.view];
Run Code Online (Sandbox Code Playgroud)

但我不知道如何在同一时间分享链接和图像.谁可以帮我这个事?

imn*_*mnk 2


您可以通过以下两种方法之一执行此操作。

1.通过SHKItem的URL属性。

@property (nonatomic, retain)   NSURL *URL;
Run Code Online (Sandbox Code Playgroud)

就像这样:

NSURL *url = [NSURL URLWithString:@"http://mobile.tutsplus.com"];
UIImage *image = [UIImage imageNamed:@"ShareKit.jpg"];
SHKItem *item = [SHKItem image:image title:@"This image was sent with ShareKit!"];
[item setURL:url];
Run Code Online (Sandbox Code Playgroud)


2.使用SHKItem的+[itemFromDictionary:]类方法

+ (SHKItem *)itemFromDictionary:(NSDictionary *)dictionary;
Run Code Online (Sandbox Code Playgroud)

就像这样:

NSString *urlString = @"http://mobile.tutsplus.com";
UIImage *image = [UIImage imageNamed:@"ShareKit.jpg"];
NSDictionary *dictionary = [NSDictionary dictionaryWithObjectsAndKeys:urlString, @"URL", image, @"image", @"This image was sent with ShareKit!", @"title", nil];
SHKItem *item = [SHKItem itemFromDictionary:dictionary];
Run Code Online (Sandbox Code Playgroud)


...然后根据需要分享您的项目。在您的情况下,您可以使用 -[actionSheetForItem:] 方法进行显示。