【问题标题】:iOS Facebook share video SwiftiOS Facebook 分享视频 Swift
【发布时间】:2017-01-26 12:24:44
【问题描述】:

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

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

我的参数委托有一个错误:

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

请注意,我在我的班级 ShareViewController。

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

【问题讨论】:

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


    【解决方案1】:

    方法showFromViewController:withContent:delegate: 期望委托参数的类型为FBSDKSharingDelegate。您提供的值类型为 ShareViewController 而不是 FBSDKSharingDelegate,这意味着所述视图控制器不符合该类型。您需要使您的视图控制器符合FBSDKSharingDelegate 类型。举个例子:

    class ShareViewController: UIViewController, FBSDKSharingDelegate {
        // code
    }
    

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

    【讨论】:

    • 感谢您的回答。但是当我尝试实现模块 FBSDKSharingDelegate 时,我的班级说她不符合。我没有(据我所知)输入 FBSDKSharingDelegate 的对象
    • @Aaron - 我也无法弄清楚如何让视频共享,但请确保您已将 FBSDKShareKit 导入到您的文件中,并且您已包含共享器功能。它们应该在出现错误时被建议,您可以使用错误的“修复”按钮自动弹出它们。
    【解决方案2】:

    您必须实现FBSDKSharingDelegate 协议及其方法。

        class ViewController: UIViewController ,FBSDKSharingDelegate{
    
        //add following methods to the class:
    func sharer(_ sharer: FBSDKSharing!, didCompleteWithResults results: [AnyHashable : Any]!) {
                print("Completed");
            }
    
    
            func sharer(_ sharer: FBSDKSharing!, didFailWithError error: Error!) {
                print("Failed with error : \(error.localizedDescription)");
            }
    
            func sharerDidCancel(_ sharer: FBSDKSharing!) {
                print("Cancelled")
            }
    
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-01-23
      • 2015-10-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多