CIGaussianBlur异常[UIImage _internalRepresentation]

时间:2015-03-09 23:33:02

标签: ios swift uiimage

我正在尝试使用以下方法静态模糊UIImage

func blurImage(image: UIImage!, blurLevel: CGFloat!) -> UIImage! {
    if self.context == nil {
        self.context = CIContext();
    }

    let inputImage = CIImage(image: image);
    let filter = CIFilter(name: "CIGaussianBlur");
    filter.setValue(image, forKey: kCIInputImageKey);
    filter.setValue(blurLevel, forKey: kCIInputRadiusKey);

    let outputImage = filter.valueForKey(kCIOutputImageKey) as CIImage;

    let outImage = self.context?.createCGImage(outputImage, fromRect: outputImage.extent());
    return UIImage(CGImage: outImage)!;
}

但调试器立即在filter.valueForKey(kCIOutputImageKey)上引发异常,通过尝试在LLDB调试器中打印对象来确认:

-[UIImage _internalRepresentation]: unrecognized selector sent to instance 0x7fef33e89b00

有谁知道为什么这个例外浮出水面?我已经尝试了各种方法的不同变体,但是根据各种堆栈溢出问题没有用,但我似乎无法弄清楚这一点......

我怀疑在经过更多调查之后,这可能仅仅是苹果公司的一个错误,但是如果有人在帮助之前遇到过这个错误

堆栈跟踪

2015-03-09 19:34:14.502 Rocks[3346:511164] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIImage _internalRepresentation]: unrecognized selector sent to instance 0x7fef33e89b00'
*** First throw call stack:
(
    0   CoreFoundation                      0x0000000112106f35 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x0000000111d9fbb7 objc_exception_throw + 45
    2   CoreFoundation                      0x000000011210e04d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
    3   CoreFoundation                      0x000000011206627c ___forwarding___ + 988
    4   CoreFoundation                      0x0000000112065e18 _CF_forwarding_prep_0 + 120
    5   CoreImage                           0x000000011192cef7 -[CIGaussianBlur outputImage] + 108
    6   Foundation                          0x000000010f939823 -[NSObject(NSKeyValueCoding) valueForKey:] + 251
    7   Rocks                                0x000000010f588024 _TFC4Rocks23LocalCollectionViewCell9blurImagefS0_FTGSQCSo7UIImage_9blurLevelGSQV12CoreGraphics7CGFloat__GSQS1__ + 3284
    8   Rocks                                0x000000010f589538 _TFC4Rocks23LocalCollectionViewCell31requestCellProfilePictureChangefS0_FGSQPSs9AnyObject__T_ + 3544
    9   Rocks                                0x000000010f58450c _TFC4Rocks29LocalCollectionViewController14collectionViewfS0_FTCSo16UICollectionView22cellForItemAtIndexPathCSo11NSIndexPath_CSo20UICollectionViewCell + 860
    10  Rocks                                0x000000010f584b6f _TToFC4Rocks29LocalCollectionViewController14collectionViewfS0_FTCSo16UICollectionView22cellForItemAtIndexPathCSo11NSIndexPath_CSo20UICollectionViewCell + 79
    11  UIKit                               0x0000000110bea41b -[UICollectionView _createPreparedCellForItemAtIndexPath:withLayoutAttributes:applyAttributes:] + 244
    12  UIKit                               0x0000000110bebb54 -[UICollectionView _updateVisibleCellsNow:] + 3445
    13  UIKit                               0x0000000110bef801 -[UICollectionView layoutSubviews] + 243
    14  UIKit                               0x0000000110635973 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 521
    15  QuartzCore                          0x00000001103a0de8 -[CALayer layoutSublayers] + 150
    16  QuartzCore                          0x0000000110395a0e _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
    17  QuartzCore                          0x000000011039587e _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
    18  QuartzCore                          0x000000011030363e _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 242
    19  QuartzCore                          0x000000011030474a _ZN2CA11Transaction6commitEv + 390
    20  UIKit                               0x00000001105ba54d -[UIApplication _reportMainSceneUpdateFinished:] + 44
    21  UIKit                               0x00000001105bb238 -[UIApplication _runWithMainScene:transitionContext:completion:] + 2642
    22  UIKit                               0x00000001105b9bf2 -[UIApplication workspaceDidEndTransaction:] + 179
    23  FrontBoardServices                  0x0000000115f0b2a3 __31-[FBSSerialQueue performAsync:]_block_invoke + 16
    24  CoreFoundation                      0x000000011203c53c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
    25  CoreFoundation                      0x0000000112032285 __CFRunLoopDoBlocks + 341
    26  CoreFoundation                      0x0000000112032045 __CFRunLoopRun + 2389
    27  CoreFoundation                      0x0000000112031486 CFRunLoopRunSpecific + 470
    28  UIKit                               0x00000001105b9669 -[UIApplication _run] + 413
    29  UIKit                               0x00000001105bc420 UIApplicationMain + 1282
    30  Rocks                                0x000000010f59262e top_level_code + 78
    31  Rocks                                0x000000010f59266a main + 42
    32  libdyld.dylib                       0x0000000112bb8145 start + 1
    33  ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

0 个答案:

没有答案