简体   繁体   English

UIImagePickerController在打开相机时崩溃

[英]UIImagePickerController crash on opening camera

I'm trying to open the camera like this: 我正在尝试像这样打开相机:

mediaPicker = [[UIImagePickerController alloc] init];
[mediaPicker setDelegate:self];
mediaPicker.allowsEditing = YES;

if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
       mediaPicker.sourceType = UIImagePickerControllerSourceTypeCamera;
       [self presentViewController:mediaPicker animated:YES completion:nil];
}

But I'm getting a crash saying: 但是我崩溃了:

-[UIImage setClipsToBounds:]: unrecognized selector sent to instance 0x1245aa9a0

Stacktrace: 堆栈跟踪:

Last Exception Backtrace:
0   CoreFoundation                  0x1812bae38 __exceptionPreprocess + 124
1   libobjc.A.dylib                 0x18091ff80 objc_exception_throw + 56
2   CoreFoundation                  0x1812c1ccc -[NSObject(NSObject) doesNotRecognizeSelector:] + 212
3   CoreFoundation                  0x1812bec74 ___forwarding___ + 872
4   CoreFoundation                  0x1811bcd1c _CF_forwarding_prep_0 + 92
5   CameraKit                       0x18a3ce460 -[CMKBlurredSnapshotView initWithView:] + 344
6   CameraKit                       0x18a40cb3c -[CMKCameraView _setupSuspensionSnapshotViewWithBlur:] + 88
7   CameraKit                       0x18a3fd0d0 -[CMKCameraView enableCamera] + 296
8   CameraKit                       0x18a3f549c -[CMKCameraView viewWillBeDisplayed] + 184
9   PhotoLibrary                    0x18c11c7d4 -[PLImagePickerCameraView viewWillBeDisplayed] + 220
10  PhotoLibrary                    0x18c0ec42c -[PLUICameraViewController viewWillAppear:] + 576
11  UIKit                           0x18641d274 -[UIViewController _setViewAppearState:isAnimating:] + 628
12  UIKit                           0x18641cfe8 -[UIViewController __viewWillAppear:] + 156
13  UIKit                           0x1864c44a0 -[UINavigationController _startTransition:fromViewController:toViewController:] + 760
14  UIKit                           0x1864c3ddc -[UINavigationController _startDeferredTransitionIfNeeded:] + 868
15  UIKit                           0x18679e904 -[UINavigationController _setViewControllers_7_0:transition:animated:operation:] + 3052
16  UIKit                           0x18679da00 -[UINavigationController _setViewControllers:transition:animated:operation:] + 620
17  UIKit                           0x18679cbfc __54-[UINavigationController setViewControllers:animated:]_block_invoke + 1232
18  UIKit                           0x1867835e4 +[UIViewController _performWithoutDeferringTransitions:] + 128
19  UIKit                           0x186543e50 -[UINavigationController setViewControllers:animated:] + 412
20  UIKit                           0x186683bd0 -[UIImagePickerController _setupControllersForCurrentSourceType] + 172
21  UIKit                           0x186683a84 -[UIImagePickerController viewWillAppear:] + 84
22  UIKit                           0x18641d274 -[UIViewController _setViewAppearState:isAnimating:] + 628
23  UIKit                           0x18641cfe8 -[UIViewController __viewWillAppear:] + 156
24  UIKit                           0x18676424c __56-[UIPresentationController runTransitionForCurrentState]_block_invoke + 960

Any ideas what might be causing this? 任何想法可能是什么原因造成的?

I've got exactly the same issue, It is caused by a swift extension which named "snapshotView() -> UIImage" extended UIView in my code. 我有完全相同的问题,这是由我的代码中一个名为“ snapshotView()-> UIImage”的扩展UIView引起的快速扩展引起的。

As the "CMKBlurredSnapshotView" in CameraKit has a same method named "snapshotView" but returning a UIView, so my code overrode the system original method but return a UIImage, So the exception is thrown. 由于CameraKit中的“ CMKBlurredSnapshotView”具有相同的名为“ snapshotView”的方法,但返回了UIView,因此我的代码覆盖了系统原始方法,但返回了UIImage,因此引发了异常。

You should check all your code and verify if you make the same mistake. 您应该检查所有代码并验证是否犯了相同的错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM