0
我無法調用推文函數。我不斷收到錯誤的參數。我也試過(AnyObject),並得到 錯誤:參數類型不符合預期...從視圖控制器調用函數 - 參數錯誤 - Swift2
我是新來的迅速,不知道如何得到這個運行。嘗試了我能想到的一切。謝謝
// from GameScene
var vc = ViewController()
vc.tweetAction(sender: AnyObject)
//error: cannot create single-element tuple with an element label
//function in View Controller below
@IBAction func tweetAction(sender: AnyObject){
if SLComposeViewController.isAvailableForServiceType(SLServiceTypeTwitter){
let tweetController = SLComposeViewController(forServiceType: SLServiceTypeTwitter)
tweetController.setInitialText("I Scored on this app")
self.presentViewController(tweetController, animated: true, completion: nil)
}
else{
let alert = UIAlertController(title: "Accounts", message: "Please log into your twitter to share", preferredStyle: UIAlertControllerStyle.Alert)
alert.addAction(UIAlertAction(title: "Dismiss", 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)
}
}
自我似乎在破解密碼按鈕。該行---------------->讓skView = self.view as! SKView拋出錯誤「Thread1信號SIGARBT, –
什麼是錯誤?是否有堆棧跟蹤? –
錯誤」線程1:信號SIGABRT「斷開的線是'let skView = self.view as!SKView',我配置view。控制檯顯示'無法將類型UIVIew的值轉換爲SKView,如果這個按鈕是一個SKSpriteNode,那麼這個按鈕就是一個SKSpriteNode –