我创建了一个应用程序,您可以在其中分享您的分数。它在iPhone上运行良好,但在iPad上它会崩溃应用程序。我一直在AppDelegate中获得“Thread 1:signal SIGABRT”。
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)
}
}
答案 0 :(得分:0)
请将此代码附加到您现有的func shareString
if youractivityView.respondsToSelector("popoverPresentationController") {
youractivityView.popoverPresentationController.sourceView = parentView
}