【发布时间】:2016-05-17 13:12:40
【问题描述】:
我正在尝试这样打开相机:
mediaPicker = [[UIImagePickerController alloc] init];
[mediaPicker setDelegate:self];
mediaPicker.allowsEditing = YES;
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
mediaPicker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentViewController:mediaPicker animated:YES completion:nil];
}
但我遇到了崩溃:
-[UIImage setClipsToBounds:]: unrecognized selector sent to instance 0x1245aa9a0
堆栈跟踪:
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
任何想法可能导致这种情况?
【问题讨论】:
-
你在 UIImage 上调用
setClipsToBounds,而它应该在 UIImageView 上调用。这就是导致崩溃的原因。告诉我们你在哪里打电话setClipsToBounds -
我不会在任何地方调用“setClipsToBounds”。
-
日志说你正在调用它或做一些调用它的事情。至于您呈现 UIImagePickerController 的代码,它是正确的。崩溃不是因为那个,而是因为我告诉你的日志
-
我仔细检查了代码,没有调用 setClipsToBounds。我猜 UIImagePickerController 在某处调用它。
-
@Anbu.Karthik
clipsToBound是一个属性。setClipsToBound是它的设置方法。日志中提到了方法又名选择器。
标签: ios objective-c camera uiimagepickercontroller