iPhone/iOS - 如何使用“ShareKit"仅发布到 Facebook 或仅发布到 Twitter [英] iPhone/iOS - How to use "ShareKit" to post only to Facebook or only to Twitter

查看:16
本文介绍了iPhone/iOS - 如何使用“ShareKit"仅发布到 Facebook 或仅发布到 Twitter的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的 iPhone 应用程序中,我有两个按钮,分别标记为Facebook"和Twitter".我想使用 Sharekit 框架,这让我的分享变得非常简单.但是如ShareKit的示例代码所示,我只能展示很多共享服务,我不想包含.我希望我的Facebook"按钮只显示 Facebook 共享服务,与 Twitter 相同.我如何修改 ShareKit 以使其像那样工作?

In my iPhone app, I have two two buttons, labeled "Facebook" and "Twitter". I want to use the Sharekit framework which makes my sharing very simple. But as shown in the sample code of ShareKit, I can only show many sharing services, which I don't want to include. I want my "Facebook" button to only show the Facebook sharing service, and the same with Twitter. How can I modify ShareKit to work like that?

推荐答案

更新:

由于这个答案仍然很受欢迎,我只是想在 iOS 5 & 中添加它iOS 6,对Sharekit 的需求要少得多.许多流行的共享选项现已内置到操作系统中.话虽如此,这个答案仍然适用于未内置在设备中的共享服务,或者如果您只是更喜欢 Sharekit.

Since this answer is still popular, I just wanted to add that with iOS 5 & iOS 6, there is much less need for Sharekit. A lot of popular sharing options are now built into the OS. That being said, this answer is still valid for the sharing services not built into the device, or if your simply more comfortable with Sharekit.

我会告诉你如何为Facebook做,Twitter完全一样,只是把Facebook的所有实例都改成Twitter

I'll show you how to do it for Facebook, Twitter is exactly the same, just change all the instances of Facebook to Twitter

首先,#import "SHKFacebook.h"然后在按钮的目标方法中,输入以下内容:

First, #import "SHKFacebook.h" then in your button's target method, put the following:

SHKItem *item;    //This creates the Sharekit Item
NSURL *url = [NSURL URLWithString:@"http://itunes.apple.com/us/app/...?mt=8"];

NSURL 应该是您在应用商店中的应用的链接.这样,如果有人在 Facebook 上看到您的应用发布的帖子并点击它,他们将被定向到商店以便他们可以下载它.严格地说,这是可选的,但您为什么不尝试通过这额外的一行来获得新的下载.

The NSURL should be a link to your app on the app store. That way if someone sees a post your app made on Facebook, and they click it, they will be directed to the store so they can download it. Strickly speaking, this is optional, but why wouldn't you try to get new downloads with this extra one line.

现在我们需要如下设置SHKItem:

Now we need to set up the SHKItem as follows:

item = [SHKItem URL:url title:[NSString stringWithFormat:@"I'm playing someGame on my iPhone! My Highscore is %i, think you can beat it?", highScoreInt]];

然后像这样设置帖子:

item = [SHKItem URL:url title:@"Share Me!"];

标题参数不能用户自定义.无论您在此处设置什么,用户都无法更改.除了您放置的任何内容之外,他们还有机会添加自己的文本.

The title parameter is NOT user customizable. Whatever you set here the user will not be able to change. They will have the opportunity to add their own text in addition to whatever you put there.

最后显示项目:

[SHKFacebook shareItem:item];

我希望这会有所帮助.正如我所说,只需将这篇文章中的 Facebook 更改为 Twitter.如果您需要更多帮助,请在评论中告诉我.

I hope this helps. As I said, just change the Facebooks in this post to Twitter. Let me know in a comment if you need more help.

这篇关于iPhone/iOS - 如何使用“ShareKit"仅发布到 Facebook 或仅发布到 Twitter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆