objective-c代码有一个问题,该代码处理打开相机拍照,将代码作为本机代码注入到代号“一”中
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
NSArray *mediaTypes = [[NSArray alloc]initWithObjects:(NSString *)kUTTypeImage, nil];
imagePicker.mediaTypes = mediaTypes;
imagePicker.cameraDevice = UIImagePickerControllerCameraDeviceRear;
[[[[[UIApplication sharedApplication] delegate] window] rootViewController] presentViewController:imagePicker animated:YES completion:nil];
}else{
[self showAlert:@"No Camera Privilege On This Device"];
}
问题是,当上述代码在iOS-11上执行时,我从codenameone中获取了空指针异常,而没有要求获得iOS-12的相机许可 代码完美运行
权限已添加到代号设置
codename1.arg.ios.NSPhotoLibraryAddUsageDescription=The App uses the Photo Library to save Images downloaded from News
codename1.arg.ios.NSCameraUsageDescription=The App uses the Camera for Video Chat support
codename1.arg.ios.NSPhotoLibraryUsageDescription=The App uses the Photo Library to save Images downloaded from News
有什么办法可以解决iOS11上的问题
-使用Xcode9.2的模拟器的异常堆栈跟踪
2018-10-04 18:47:50.830359+0300 TestApplication[7630:35311] *** Assertion failure in -[UIApplication _cachedSystemAnimationFenceCreatingIfNecessary:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3698.33.6/UIApplication.m:1709
2018-10-04 18:47:50.853277+0300 TestApplication[7630:35311] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'accessing _cachedSystemAnimationFence requires the main thread'
*** First throw call stack:
(
0 CoreFoundation 0x000000010da7312b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000010d107f41 objc_exception_throw + 48
2 CoreFoundation 0x000000010da782f2 +[NSException raise:format:arguments:] + 98
3 Foundation 0x0000000109d38d69 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 193
4 UIKit 0x0000000107ac692d -[UIApplication _cachedSystemAnimationFenceCreatingIfNecessary:] + 359
5 UIKit 0x0000000107b51ac9 +[UIWindow _synchronizeDrawingWithPreCommitHandler:] + 57
6 UIKit 0x00000001082cfb7b -[UIInputViewAnimationStyle launchAnimation:afterStarted:completion:forHost:fromCurrentPosition:] + 99
7 UIKit 0x000000010872be9a -[UIInputWindowController moveFromPlacement:toPlacement:starting:completion:] + 1697
8 UIKit 0x0000000108734c8f __43-[UIInputWindowController setInputViewSet:]_block_invoke.1493 + 97
9 UIKit 0x0000000108724208 -[UIInputWindowController performOperations:withTemplateNotificationInfo:] + 46
10 UIKit 0x000000010873481b -[UIInputWindowController setInputViewSet:] + 1336
11 UIKit 0x000000010872b450 -[UIInputWindowController performOperations:withAnimationStyle:] + 50
12 UIKit 0x00000001082c8164 -[UIPeripheralHost(UIKitInternal) setInputViews:animationStyle:] + 1669
13 UIKit 0x00000001082bff4b -[UIPeripheralHost(UIKitInternal) _reloadInputViewsForResponder:] + 2163
14 UIKit 0x00000001082c9480 -[UIPeripheralHost(UIKitInternal) _preserveInputViewsWithId:animated:reset:] + 498
15 UIKit 0x0000000107c89130 -[UIViewController _presentViewController:modalSourceViewController:presentationController:animationController:interactionController:completion:] + 1233
16 UIKit 0x0000000107c8ae94 -[UIViewController _presentViewController:withAnimationController:completion:] + 4621
17 UIKit 0x0000000107c8d9a9 __63-[UIViewController _presentViewController:animated:completion:]_block_invoke + 99
18 UIKit 0x0000000107c8e079 -[UIViewController _performCoordinatedPresentOrDismiss:animated:] + 532
19 UIKit 0x0000000107c8d908 -[UIViewController _presentViewController:animated:completion:] + 181
20 UIKit 0x0000000107c8dc67 -[UIViewController presentViewController:animated:completion:] + 159
感谢帮助
此致
答案 0 :(得分:0)
感谢您的所有帮助,所述问题仅在iOS11上存在,其原因是如果我向我展示任何带有animation的viewcontroller:是的,我通过添加以下代码更改了如何调用视图控制器
ServicePointManager.ServerCertificateValidationCallback =
delegate (
object s,
X509Certificate certificate,
X509Chain chain,
SslPolicyErrors sslPolicyErrors
) {
return true;
};
和showForm:只需复制一个旧的viewcontroller并显示一个新的viewcontroller即可[条件用于等待相机完成拾取并将文件保存到图库]:
dispatch_queue_t _serialQueue = dispatch_queue_create("x.y.z", DISPATCH_QUEUE_CONCURRENT);
dispatch_sync(_serialQueue, ^{
self.filePath=param;
[self showForm];
});
我希望这对任何需要它的人都有帮助
此致