首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >本机代码捕获图像在IOS 11上抛出异常?

本机代码捕获图像在IOS 11上抛出异常?
EN

Stack Overflow用户
提问于 2018-10-04 15:00:41
回答 1查看 162关注 0票数 1

我遇到了一个目标-c代码的问题,它处理打开相机来拍摄一张照片,代码作为本机代码注入到一个代码中。

代码语言:javascript
复制
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。

该权限将添加到代码集中。

代码语言:javascript
复制
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从模拟器跟踪异常堆栈

代码语言:javascript
复制
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

感谢你的帮助

致以敬意,

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-10-05 07:25:01

谢谢您的帮助,问题只出现在iOS11上,如果我给出任何带有动画的视图控制器,原因是:是的,我通过添加以下代码更改了如何调用视图控制器

代码语言:javascript
复制
dispatch_queue_t _serialQueue = dispatch_queue_create("x.y.z", DISPATCH_QUEUE_CONCURRENT);
dispatch_sync(_serialQueue, ^{
        self.filePath=param;
        [self showForm];

    });

showForm :只需获取旧视图控制器的副本,并呈现新的视图控制器,就像用于等待摄像机完成挑选并保存到图库中的文件那样:

代码语言:javascript
复制
-(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];



}

我希望这能帮助任何需要它的人

致以敬意,

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52649895

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档