本机代码捕获图像在 IOS 11 上引发异常?
Native Code Capture Image throws exception on IOS 11?
我有一个问题 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 上执行时,与 iOS-12 不同,我在没有请求相机许可的情况下从 codenameone 得到空指针异常
代码完美运行
代号设置中添加了权限
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
感谢帮助
此致,
感谢您的所有帮助,所述问题仅出现在 iOS11 上,如果我用 animated:Yes 显示任何 viewcontroller 并且我更改了方法通过添加以下代码
来调用视图控制器
dispatch_queue_t _serialQueue = dispatch_queue_create("x.y.z", DISPATCH_QUEUE_CONCURRENT);
dispatch_sync(_serialQueue, ^{
self.filePath=param;
[self showForm];
});
和 showForm :只需复制旧的 viewcontroller 并像这样展示新的 [条件用于等待相机完成拾取并将文件保存到图库] :
-(void)showForm{
condition = [[NSCondition alloc] init];
self.parentViewController = [[[[UIApplication sharedApplication] delegate] window] rootViewController];
[self.parentViewController.view setUserInteractionEnabled:NO];
destinationViewController = [[ViewController alloc] initWithValues:self.filePath andCondition:condition andChoice:@"Camera"];
[[[[[UIApplication sharedApplication] delegate] window] rootViewController] presentViewController:destinationViewController animated:NO completion:nil];
[condition lock];
[condition wait];
self.filePath = [(ViewController*)destinationViewController getImagePath];
[self.parentViewController.view setUserInteractionEnabled:YES];
[condition unlock];
}
希望对需要的人有所帮助
此致,
我有一个问题 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 上执行时,与 iOS-12 不同,我在没有请求相机许可的情况下从 codenameone 得到空指针异常 代码完美运行
代号设置中添加了权限
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
感谢帮助
此致,
感谢您的所有帮助,所述问题仅出现在 iOS11 上,如果我用 animated:Yes 显示任何 viewcontroller 并且我更改了方法通过添加以下代码
来调用视图控制器dispatch_queue_t _serialQueue = dispatch_queue_create("x.y.z", DISPATCH_QUEUE_CONCURRENT);
dispatch_sync(_serialQueue, ^{
self.filePath=param;
[self showForm];
});
和 showForm :只需复制旧的 viewcontroller 并像这样展示新的 [条件用于等待相机完成拾取并将文件保存到图库] :
-(void)showForm{
condition = [[NSCondition alloc] init];
self.parentViewController = [[[[UIApplication sharedApplication] delegate] window] rootViewController];
[self.parentViewController.view setUserInteractionEnabled:NO];
destinationViewController = [[ViewController alloc] initWithValues:self.filePath andCondition:condition andChoice:@"Camera"];
[[[[[UIApplication sharedApplication] delegate] window] rootViewController] presentViewController:destinationViewController animated:NO completion:nil];
[condition lock];
[condition wait];
self.filePath = [(ViewController*)destinationViewController getImagePath];
[self.parentViewController.view setUserInteractionEnabled:YES];
[condition unlock];
}
希望对需要的人有所帮助
此致,