6

私は孤独な画像を共有する方法を知っています:

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

孤独なリンクを共有する方法:

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

しかし、リンクと画像の両方を同時に共有する方法がわかりません。誰かがこれについて私を助けることができますか?

4

1 に答える 1

2


これは 2 つの方法のいずれかで実行できます。

1. SHKItem の URL プロパティを介して。

@property (nonatomic, retain)   NSURL *URL;

そのようです:

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. SHKItem の +[itemFromDictionary:] クラス メソッドを使用する

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

そのようです:

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


...そして、必要に応じてアイテムを共有します。あなたの場合、 -[actionSheetForItem:] メソッドを使用して表示できます。

于 2012-04-16T13:34:12.230 に答える