Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sharing multiples items with sharekit on facebook

I know how to share an image lonely:

// 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];

and how to share a link lonely:

// 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];

but I don't know how to share both link and image in the same time. Can anyone help me on this?

like image 235
user821470 Avatar asked Jun 29 '11 15:06

user821470


1 Answers


You can do this one of two ways.

1. Through the URL property of SHKItem.

@property (nonatomic, retain)   NSURL *URL;

Like so:

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];


2. Using the +[itemFromDictionary:] class method of SHKItem

+ (SHKItem *)itemFromDictionary:(NSDictionary *)dictionary;

Like so:

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];


... and then sharing your item as desired. In your case, you can display using the -[actionSheetForItem:] method.

like image 101
imnk Avatar answered Sep 21 '22 10:09

imnk