【发布时间】:2018-03-02 13:48:57
【问题描述】:
亲爱的,我收到一个错误“'GameScene' 类型的值没有成员'present'”
我想添加一个标签以在 facebook 中分享最佳分数,下面的代码在普通 ViewController 中可以正常工作
for touch in touches {
let touchLocation = touch.location(in: self)
if atPoint(touchLocation).name == "shareButtoon" {
if SLComposeViewController.isAvailable(forServiceType: SLServiceTypeFacebook) {
let facebookSheet:SLComposeViewController = SLComposeViewController(forServiceType: SLServiceTypeFacebook)
facebookSheet.setInitialText(bestScore.text)
self.present(facebookSheet, animated: true, completion: nil)
} else {
let alert = UIAlertController(title: "Accounts", message: "Please login to your Facebook account", preferredStyle: UIAlertControllerStyle.alert)
alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: nil))
self.present(alert, animated: true, completion: nil)
}
}
}
【问题讨论】: