UIActivity视图控制器崩溃

时间:2015-06-14 23:45:46

标签: ios sprite-kit uiactivityviewcontroller

我有一个活动控制器,有时会崩溃,我不明白为什么。这是我的代码:

extension UIView {
var snapshot: UIImage {
    UIGraphicsBeginImageContextWithOptions(bounds.size, false, UIScreen.mainScreen().scale)
    drawViewHierarchyInRect(bounds, afterScreenUpdates: true)
    let result = UIGraphicsGetImageFromCurrentImageContext()
    UIGraphicsEndImageContext()
    return result
}
}

这是我的UIView快照扩展:

Thread : Fatal Exception: NSGenericException
0  CoreFoundation                 0x25a14fef __exceptionPreprocess
1  libobjc.A.dylib                0x33e00c8b objc_exception_throw
2  UIKit                          0x2970ae63 -[UIPopoverPresentationController presentationTransitionWillBegin]
3  UIKit                          0x2934209d __71-[UIPresentationController _initViewHierarchyForPresentationSuperview:]_block_invoke
4  UIKit                          0x29340a17 __56-[UIPresentationController runTransitionForCurrentState]_block_invoke
5  UIKit                          0x290e4a91 _applyBlockToCFArrayCopiedToStack
6  UIKit                          0x2905f38f _afterCACommitHandler
7  CoreFoundation                 0x259dafed __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__
8  CoreFoundation                 0x259d86ab __CFRunLoopDoObservers
9  CoreFoundation                 0x259d8ab3 __CFRunLoopRun
10 CoreFoundation                 0x25925201 CFRunLoopRunSpecific
11 CoreFoundation                 0x25925013 CFRunLoopRunInMode
12 GraphicsServices               0x2d101201 GSEventRunModal
13 UIKit                          0x290c9a59 UIApplicationMain
14 A Void                         0x000ba600 main (AppDelegate.swift:19)
15 libdyld.dylib                  0x3438caaf start

以下是我得到的错误:

Thread : Crashed: com.apple.main-thread
0  A Void                         0x0013aa90 function signature specialization <Arg[0] = Owned To Guaranteed and Exploded, Arg[1] = Owned To Guaranteed, Arg[2] = Owned To Guaranteed> of A_Void.GameScene.touchesMoved (A_Void.GameScene)(Swift.Set<ObjectiveC.NSObject>, withEvent : ObjectiveC.UIEvent) -> () (GameScene.swift:2036)
1  A Void                         0x0013a950 function signature specialization <Arg[0] = Owned To Guaranteed and Exploded, Arg[1] = Owned To Guaranteed, Arg[2] = Owned To Guaranteed> of A_Void.GameScene.touchesMoved (A_Void.GameScene)(Swift.Set<ObjectiveC.NSObject>, withEvent : ObjectiveC.UIEvent) -> () (GameScene.swift:2026)
2  A Void                         0x0010b2bc @objc A_Void.GameScene.touchesMoved (A_Void.GameScene)(Swift.Set<ObjectiveC.NSObject>, withEvent : ObjectiveC.UIEvent) -> () (GameScene.swift)
3  SpriteKit                      0x28f0a8af -[SKView touchesMoved:withEvent:] + 710
4  UIKit                          0x2909a46b -[UIWindow _sendTouchesForEvent:] + 350
5  UIKit                          0x29093df1 -[UIWindow sendEvent:] + 544
6  UIKit                          0x29069fe5 -[UIApplication sendEvent:] + 196
7  UIKit                          0x292e08fb _UIApplicationHandleEventFromQueueEvent + 14414
8  UIKit                          0x290689f9 _UIApplicationHandleEventQueue + 1352
9  CoreFoundation                 0x259dafaf __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 14
10 CoreFoundation                 0x259da3bf __CFRunLoopDoSources0 + 218
11 CoreFoundation                 0x259d8a25 __CFRunLoopRun + 772
12 CoreFoundation                 0x25925201 CFRunLoopRunSpecific + 476
13 CoreFoundation                 0x25925013 CFRunLoopRunInMode + 106
14 GraphicsServices               0x2d101201 GSEventRunModal + 136
15 UIKit                          0x290c9a59 UIApplicationMain + 1440
16 A Void                         0x0014d600 main (AppDelegate.swift:19)
17 libdyld.dylib                  0x3438caaf start + 2

library(ggplot2)

ggplot(data = mtcars, aes(x = mpg, fill = factor(cyl))) +
  geom_histogram(aes(y = ..density..)) +
  geom_line(stat = "density")

该应用程序是一个用精灵套件制作的游戏,所以我在SKScene中调用这个游戏方法。此外,游戏视图控制器是一个控制游戏场景并且它是嵌入导航视图控制器,其中我呈现游戏中心。有人知道如何解决这个问题吗?

0 个答案:

没有答案