0
我試圖導入twitter的社交框架,並在社交按鈕被按下時調用視圖。這是我的代碼,我得到「類型'GameOverScene'的值沒有成員'present'」,我試圖呈現視圖。當前視圖:Swift 3
if SLComposeViewController.isAvailable(forServiceType: SLServiceTypeTwitter) {
let tweetController = SLComposeViewController(forServiceType: SLServiceTypeTwitter)
tweetController?.setInitialText("I Scored \(scoreNumber) on Gone Dots! You can try by downloading Gone Dots from the app store for free")
self.present(tweetController, animated: true, completion: true)
} else {
let alert = UIAlertController(title: "Account", message: "Plese log into Twitter", preferredStyle: UIAlertControllerStyle.alert)
alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: nil))
alert.addAction(UIAlertAction(title: "Settings", style: UIAlertActionStyle.default, handler: {
(UIAlertAction) in
let settingsURL = NSURL(string: UIApplicationOpenSettingsURLString)
if let url = settingsURL{
UIApplication.shared.openURL(url as URL)
}
}))
self.present(alert, animated: true, completion: true)
}
非常感謝我使用UIActivityViewController及其工作 –