作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我尝试将 Open Graph Story 与最新的 Facebook SDK for Swift 集成,但收到错误“无法推断通用参数“内容””
let object: OpenGraphObject = [
"og:type": "books.book",
"og:title": "A Game of Thrones",
"og:description": "In the frozen wastes to the north of Winterfell, sinister and supernatural forces are mustering.",
"books:isbn": "0-553-57340-3"
]
// Create an action
var action = OpenGraphAction(type: "book.reads")
action["books:book"] = object
// Create the content
var content = OpenGraphShareContent()
content.action = action
content.previewPropertyName = "books:book"
try ShareDialog.show(from: self, content: content) //Here i'm getting "generic parameter 'Content' could not be inferred"
有人知道解决办法吗?
最佳答案
据我从 commit log 中了解到的,该模块不再维护。相反,请使用 FBSDKShareKit
模块(例如来自 Cocoapods 的 use_frameworks!
)。那么你应该能够做到
import FBSDKShareKit
...
// Create an object
let object = FBSDKShareOpenGraphObject.init(properties: [
"og:type": "books.book",
"og:title": "A Game of Thrones",
"og:description": "In the frozen wastes to the north of Winterfell, sinister and supernatural forces are mustering.",
"books:isbn": "0-553-57340-3"
])
// Create an action
let action = FBSDKShareOpenGraphAction.init()
action.actionType = "books.reads"
action.setObject(object, forKey: "books:book")
// Create the content
let content = FBSDKShareOpenGraphContent.init()
content.action = action
content.previewPropertyName = "books:book"
FBSDKShareDialog.show(from: self, with: content, delegate: self)
关于swift - swift3 上的 Facebook OpenGraphContent,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41888825/
我尝试将 Open Graph Story 与最新的 Facebook SDK for Swift 集成,但收到错误“无法推断通用参数“内容”” let object: OpenGraphObject
我是一名优秀的程序员,十分优秀!