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

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

问题描述

在我的iPhone应用程序中,我有两个标签为Facebook和Twitter的两个按钮。
我想使用 Sharekit 框架,这使我的分享非常简单。但是如ShareKit的示例代码所示,我只能显示许多共享服务,我不想包含。我想要我的Facebook按钮只显示Facebook共享服务,和Twitter一样。如何修改ShareKit这样工作?

解决方案

更新



由于这个答案仍然很受欢迎,我只想补充说,iOS 5& iOS 6,对 Sharekit 的需求要少得多。操作系统中现在内置了很多流行的共享选项。话虽如此,这个答案仍然适用于没有内置在设备中的共享服务,或者如果你更喜欢Sharekit。





$ b $我会告诉你如何做Facebook,Twitter是完全一样的,只是将Facebook的所有实例更改为Twitter



首先, #importSHKFacebook.h
然后在您的按钮的目标方法中,放置以下内容:

  SHKItem * item; //这创建了Sharekit项
NSURL * url = [NSURL URLWithString:@http://itunes.apple.com/us/app/...?mt=8];

NSURL 应该是您的应用在应用商店。这样,如果有人看到您在Facebook上发布的应用程序,并点击它,他们将被引导到商店,以便他们可以下载它。 Strickly说,这是可选的,但是为什么不尝试通过额外的一行获得新的下载。



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

  item = [SHKItem URL:url title:[NSString stringWithFormat: @我在我的iPhone上玩了一些游戏!我的Highscore是%我认为你可以打败它?,highScoreInt]]; 

然后设置帖子如下:

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

标题参数是用户可自定义的。无论您在这里设置什么,用户将无法更改。他们将有机会添加自己的文本,除了你放在那里。



最后显示项目:

  [SHKFacebook shareItem:item]; 

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


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?

解决方案

Update:

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.


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

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

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.

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

Then set up the post like this:

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.

Finally show the item:

[SHKFacebook shareItem:item];

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天全站免登陆