在GameScene
把这个在您的touchesBegan方法
注意 -即shareBtn是var shareBtn = SKSpriteNode()
for touch in touches {
if isDead == true {
let location = touch.location(in: self)
if shareBtn.contains(location) {
if var top = scene?.view?.window?.rootViewController {
while let presentedViewController = top.presentedViewController {
top = presentedViewController
}
let activityVC = UIActivityViewController(activityItems: ["Can you beat my Score of \(score) in Crappy Duck?"], applicationActivities: nil)
activityVC.popoverPresentationController?.sourceView = view
top.present(activityVC, animated: true, completion: nil)
}
}
}
}
我真的不知道为什么这个工程我从this question
得到了它