0

I've created an app where you can share your score. It works great on the iPhones, but on the iPads it crashes the app. I keep getting a "Thread 1: signal SIGABRT" in the AppDelegate.

class GameViewController: UIViewController, GameSceneDelegate {

    override func viewDidLoad() {
        super.viewDidLoad()
        if let skView = self.view as? SKView {
            if skView.scene == nil{

                // create the scene

                let scene = GameScene(size: CGSize(width: 2048, height: 1536), delegate: self, gameState: .MainMenu)
                skView.showsFPS = false
                skView.showsNodeCount = false
                skView.ignoresSiblingOrder = true

                scene.scaleMode = .AspectFill

                skView.presentScene(scene)

            }
        }
        self.canDisplayBannerAds = true


    }
    override func prefersStatusBarHidden() -> Bool {
        return true
    }

    func screenshot() -> UIImage {


        UIGraphicsBeginImageContextWithOptions(view.bounds.size, false, 1.0)
        view.drawViewHierarchyInRect(view.bounds, afterScreenUpdates: true)
        let image = UIGraphicsGetImageFromCurrentImageContext()
        UIGraphicsEndImageContext()
        return image


    }

    func shareString(string: String, url: NSURL, image: UIImage) {
        let vc = UIActivityViewController(activityItems: [string, url, image], applicationActivities: nil)
        presentViewController(vc, animated: true, completion: nil)
    }
}
Cong Tran
  • 1,448
  • 14
  • 30
Joel
  • 1
  • 2
  • Possible duplicate of [Thread 1: signal SIGABRT IOS Xcode 5](http://stackoverflow.com/questions/19369310/thread-1-signal-sigabrt-ios-xcode-5) – Anbu.Karthik Dec 09 '15 at 06:52

1 Answers1

0

Please attach this code with your exsiting func shareString

if youractivityView.respondsToSelector("popoverPresentationController") {
        youractivityView.popoverPresentationController.sourceView = parentView
    }
Anil solanki
  • 962
  • 4
  • 20