iOS Facebook 分享视频 Swift

标签 ios swift facebook facebook-graph-api facebook-sdk-4.0

我正在寻找一种在 Facebook 上分享我的申请视频的方法。 我将 SDK 安装到 facebook 并按照说明操作,但我不明白为什么我不能分享我的视频。

let fbVideo:FBSDKShareVideo = FBSDKShareVideo()
fbVideo.videoURL = url
let content: FBSDKShareVideoContent = FBSDKShareVideoContent()
content.video = fbVideo
FBSDKShareDialog.showFromViewController(self, withContent: content, delegate: self)

我有一个关于参数委托(delegate)的错误:

Cannot convert value of type 'ShareViewController' to expected argument type 'FBSDKSharingDelegate!'

请注意,我在我的类(class) ShareViewController 中。

没有其他方法可以在 Facebook 上分享视频吗?谢谢

最佳答案

showFromViewController:withContent:delegate: 方法期望委托(delegate)参数的类型为 FBSDKSharingDelegate。您提供的值类型为 ShareViewController 而不是 FBSDKSharingDelegate 这意味着所述 View Controller 不符合该类型。您需要使您的 View Controller 符合 FBSDKSharingDelegate 类型。例如:

class ShareViewController: UIViewController, FBSDKSharingDelegate {
    // code
}

或者传入另一个符合类型FBSDKSharingDelegate的对象。

关于iOS Facebook 分享视频 Swift,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39562564/

相关文章:

ios - Firebase 功能更新 strip 用户

ios - YouTube - 下载/播放私有(private)视频

objective-c - 如何让编译器默认使用 `nullable`

javascript - Facebook Like "total likes"-回调?

facebook - 如何在我自己的 Facebook 应用程序中重复使用 Facebook 的电影自动完成功能?

ios - NSTimeZone.localTimeZone().secondsFromGMT 崩溃

objective-c - 在 iOS 中使用相对位置布局 View 的最佳方式?

iphone - 释放appDelegate实例?

ios - 如何以编程方式在 iOS 中单击 facebook loginView?

ios - NSLocation 不等我点击允许