iphone - 在 Facebook 上使用 sharekit 共享多个项目

标签 iphone ios facebook 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];

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

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

但我不知道如何同时分享链接和图片。谁能帮我解决这个问题?

最佳答案


您可以选择以下两种方式之一。

<强>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:] 方法显示。

关于iphone - 在 Facebook 上使用 sharekit 共享多个项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6523592/

相关文章:

iphone - 如何从 NSData 对象中获取值

ios - 用新的 UIView 替换 self.view 显示黑色 View

ios - UITableView 仅显示提要中的 1 个单元格。休息套件

iphone - 我必须使用 iOS 应用程序内购买来支付每月可变金额的服务账单吗?

ios - 如何调用 UIWebview 的委托(delegate)方法?

ios - AFNetworking 参数序列化错误

android - Facebook - 像浏览器一样在 webview 中显示 facebook 用户 Feed

javascript - <div id ="fb-root"和 JS 的最佳位置在哪里?

php - 无法连接到 graph.facebook.com 端口 443 : Network unreachable

ios - 如何在 iPhone 中快速重播通知,如 whats app 或 iMessage?