だから、UIアクティビティを開く共有ボタンがあります。共有ボタンをクリックするとクラッシュし、このエラーが表示されます:libc++abi.dylib: terminating with uncaught exception of type NSException
。誰かが自分のコードをチェックして、何が起こっているか見ることができますか?ありがとう *最後のものも1つ:ゲームに戻ったときに共有ボタンが画面に残ります。私はそれを隠すことができますか?ゲームオーバーシーンでしか表示しないでください。SpriteKitで共有ボタンがクラッシュしていますか?
here is my code
shareButton = UIButton(frame: CGRect(x: 0, y:0, width: view.frame.size.width/3, height: 60))
// shareButton.center = CGPoint(x: self.size.width/4, y: self.size.height/4)
shareButton.center = CGPoint(x: view.frame.size.width/2 - 70, y: view.frame.size.height/1.275)
shareButton.center = CGPoint(x: self.frame.midX, y: 3*self.frame.height/4)
shareButton.setTitle("Share", for: UIControlState.normal)
shareButton.setTitleColor(UIColor.white, for: UIControlState.normal)
shareButton.addTarget(self, action: (#selector(GameOver.pressed(_:))), for: .touchUpInside)
// shareButton.removeFromSuperview()
self.view?.addSubview(shareButton)
func pressed(_ sender: UIButton!) {
let va = self.view?.window?.rootViewController
let myText = "Can you beat my score \(score) in the game of Balls"
let activityVC:UIActivityViewController = UIActivityViewController(activityItems: [myText], applicationActivities: nil)
va?.present(activityVC, animated: true, completion: nil)
}
「GameOver」とは何ですか?それはクラスですか? – Bali
はい、あなたがself.present(activityVC、animated:true、completion:nil)を使ってそのactivityVCを提示していないのは、クラス –
です。 – KKRocks