我可能有一个非常愚蠢的问题。我在SpriteKit游戏上工作,我希望用户能够在Facebook和Twitter上分享他们的Highscores。 帖子应包含文字和图片。 我的代码与Twitter合作但不与Facebook合作,我不知道为什么.. 这是Facebook的一部分:
#import <Social/Social.h>
...
SLComposeViewController *facebookSheet = [SLComposeViewController composeViewControllerForServiceType: SLServiceTypeFacebook];
facebookSheet.completionHandler = ^(SLComposeViewControllerResult result) {
switch(result) {
case SLComposeViewControllerResultCancelled:
break;
case SLComposeViewControllerResultDone:
break;
}
};
[facebookSheet setInitialText:[_playerName stringByAppendingString: @" has a new Highscore"]];
[facebookSheet addImage:[UIImage imageNamed:_HighscoreImage]];
UIViewController *controller = self.view.window.rootViewController;
[controller presentViewController:facebookSheet animated: YES completion:nil];
答案 0 :(得分:1)
要解决此问题,我们可以选择FBSDKSharKit.Install FBSDK pod文件。
if UIApplication.sharedApplication().canOpenURL(NSURL(string: "fb:")!) {
let content : FBSDKShareLinkContent = FBSDKShareLinkContent()
content.contentURL = NSURL(string: "https://google.com")
content.contentTitle = "Test"
content.contentDescription = "FBSDKShareKit is an alternative to this issue"
content.imageURL = NSURL(string:"https://pixabay.com/static/uploads/photo/2015/10/01/21/39/background-image-967820_960_720.jpg")
let ShareKit: FBSDKShareDialog = FBSDKShareDialog()
ShareKit.fromViewController = self;
ShareKit.shareContent = content
ShareKit.mode = FBSDKShareDialogMode.FeedBrowser
ShareKit.show()
}
有关使用ShareKit的详细说明,请查看我的其他answer。