Ios 在Swift的SKScene中调用.presenttoViewController
我正在用斯威夫特的精灵装备做游戏。当你在游戏中死亡时,它提供了在Twitter、Facebook等网站上分享你的分数的选项。但是由于我在一个场景中,它没有member.presentViewController。我需要呈现Twitter撰写字段,有什么方法可以做到这一点吗 代码如下:Ios 在Swift的SKScene中调用.presenttoViewController,ios,swift,facebook,skscene,Ios,Swift,Facebook,Skscene,我正在用斯威夫特的精灵装备做游戏。当你在游戏中死亡时,它提供了在Twitter、Facebook等网站上分享你的分数的选项。但是由于我在一个场景中,它没有member.presentViewController。我需要呈现Twitter撰写字段,有什么方法可以做到这一点吗 代码如下: if SLComposeViewController.isAvailableForServiceType(SLServiceTypeTwitter) { let tweetviewcontr
if SLComposeViewController.isAvailableForServiceType(SLServiceTypeTwitter) {
let tweetviewcontroller = SLComposeViewController(forServiceType: SLServiceTypeTwitter)
tweetviewcontroller.setInitialText("I Scored \(score) on Cube Falling")
self.presentViewController(tweetviewcontroller, animated: true, completion: nil)
} else {
let alert = UIAlertController(title: "Accounts", message: "Please login to your Twitter account", preferredStyle: UIAlertControllerStyle.Alert)
alert.addAction(UIAlertAction(title: "Okay", 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.sharedApplication().openURL(url)
}
}))
self.presentViewController(alert, animated: true, completion: nil)
}
以下是错误:
谢谢
SKScene
没有名为presentViewController:animated:completion:
的成员。。。该方法是UIViewController
类的一部分。是的,我知道,但是还有什么方法可以继续执行演示文稿吗?@whirwind你搜索过了吗?这里有很多类似的帖子。我在Swift中尝试过的所有帖子都没有在Whirlwind中起作用