gpt4 book ai didi

ios - 快速发布到 Facebook 不起作用?

转载 作者:行者123 更新时间:2023-11-28 13:09:59 27 4
gpt4 key购买 nike

我正在尝试将照片发布到 Facebook,使用以下代码可以正常工作:

   func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [NSObject : AnyObject]) {

self.selectedImage = info[UIImagePickerControllerOriginalImage] as! UIImage

var photo = FBSDKSharePhoto()
photo.image = self.selectedImage
photo.userGenerated = true

var content = FBSDKSharePhotoContent()
content.photos = [photo]


self.dismissViewControllerAnimated(true, completion: nil)

shareDialog.fromViewController = self
shareDialog.shareContent = content
shareDialog.show()

}

但是,这仅在用户下载了 facebook 应用程序时有效。否则它不会打开网络浏览器来分享照片,即使 facebook 声明:

The Share Dialog switches to the native Facebook for iOS app, then returns control to your app after a post is published. If someone doesn't have Facebook app installed it will automatically falls back to a web-based dialog.

有什么建议吗?感谢回答,谢谢。

最佳答案

你可以试试这个:

func postToFacebook(image: UIImage!) {
var SocialMedia :SLComposeViewController = SLComposeViewController(forServiceType: SLServiceTypeFacebook)
SocialMedia.completionHandler = {
result -> Void in
var getResult = result as SLComposeViewControllerResult;
switch(getResult.rawValue) {
case SLComposeViewControllerResult.Cancelled.rawValue: println("Cancelled")
case SLComposeViewControllerResult.Done.rawValue: println("It's Work!")
default: println("Error!")
}
self.dismissViewControllerAnimated(true, completion: nil)
}
self.presentViewController(SocialMedia, animated: true, completion: nil)
SocialMedia.setInitialText("...")
SocialMedia.addImage(image)
}

关于ios - 快速发布到 Facebook 不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31702300/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com