[英]App crashes for share button on iPad
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.
它在 iPhone 上运行良好,但在 iPad 上它会使应用程序崩溃。 I keep getting a "Thread 1: signal SIGABRT" in the AppDelegate.
我一直在 AppDelegate 中收到“线程 1:信号 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)
}
}
Please attach this code with your exsiting func shareString请将此代码与您现有的 func shareString 一起附加
if youractivityView.respondsToSelector("popoverPresentationController") {
youractivityView.popoverPresentationController.sourceView = parentView
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.