简体   繁体   English

如何在字符串上制作超链接并在Facebook上分享[iOS]

[英]How to make hyperlink on a String and share in Facebook [iOS]

I have a NSString which one I use for share on Facebook & Twitter . 我有一个NSString ,我用它在FacebookTwitter分享 My requirement is that text will be a link after share on Facebook . 我的要求是文本将成为Facebook分享后的链接。 On Facebook when user click on that text, then direct go to that link. Facebook上,当用户点击该文本时,然后直接转到该链接。

My code is like below: 我的代码如下:

NSInteger Score = [[NSUserDefaults standardUserDefaults] integerForKey:@"K_ScoreVal"];

SLComposeViewController *Facebooksheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
[Facebooksheet setInitialText:[NSString stringWithFormat:@"I just completed level 1.1 and score is %d points.",Score]];
[[CCDirector sharedDirector] presentViewController:Facebooksheet animated:YES completion:nil];

I just completed level 1.1 and score is 455 points. 我刚刚完成了1.1级,得分为455分。 This is my text, which one I share on Facebook . 这是我的文字,我在Facebook分享 But when user click on this text, then direct go to a link. 但是当用户单击此文本时,请直接转到链接。 Meanwhile I want to make this text as a hyperlink. 同时我想把这个文本作为一个超链接。

Please suggest me. 请建议我。

What you really want to use is the OpenGraph API for games. 你真正想要使用的是用于游戏的OpenGraph API。 Have a look at the introduction docs at https://developers.facebook.com/docs/games/opengraph/ 请访问https://developers.facebook.com/docs/games/opengraph/查看介绍文档。

If you go down this road, you can use the 如果你走这条路,你可以使用

你尝试过使用Attributed Strings吗?

NSString *shareString = [[NSAttributedString alloc] initWithString:@"I just completed level 1.1 and score is 455 points." attributes:@{NSLinkAttributeName: @"http://yourlink.com"}];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM