iPhone App崩溃错误[UIApplication _cachedSystemAnimationFenceCreatingIfNecessary:] [英] iPhone App Crash with error [UIApplication _cachedSystemAnimationFenceCreatingIfNecessary:]

查看:748
本文介绍了iPhone App崩溃错误[UIApplication _cachedSystemAnimationFenceCreatingIfNecessary:]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在应用程序商店中有一个使用Touch ID的iPhone应用程序。如果启用了Touch ID,则用户通过它进行身份验证,否则用户需要输入他的PIN才能登录该应用程序。

I have an iPhone App in the app store which is using Touch ID. If Touch ID is enabled, the user is authenticated with it, else user needs to enter his PIN to login to the application.

IOS 10.1发布后,我检查了崩溃报告,崩溃计数增加了。从崩溃报告中,它指向 [UIApplication _cachedSystemAnimationFenceCreatingIfNecessary:] ,当我在Xcode中打开应用程序时,它专注于 [self dismissViewControllerAnimated:是完成:nil];

After IOS 10.1 release, when I checked the crash report, the crash count has increased. From the crash report, it is pointing on [UIApplication _cachedSystemAnimationFenceCreatingIfNecessary:] and when I opened the app in Xcode, it is focussing on [self dismissViewControllerAnimated:YES completion:nil];.

我编写的代码如下:

-(void) showTouchIDAuthentication{

    LAContext *myContext = [[LAContext alloc] init];
    NSError *authError = nil;
    NSString *myLocalizedReasonString = @"Authenticate using your finger to access My Account Menu.";
    if ([myContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&authError]) {
        [myContext evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics
                  localizedReason:myLocalizedReasonString
                            reply:^(BOOL success, NSError *error) {
                                if (success) {
                                    NSLog(@"User is authenticated successfully");
                                    [self dismissViewControllerAnimated:YES completion:nil];
                                } else {
   }];
    }

}

当我在iPhone 6中测试时, IOS 10,一切正常。不知道如何模拟这个问题。

When I tested in iPhone 6, IOS 10, everything is working fine. Don't know how to simulate the issue.

任何人都可以弄清楚我是否遗漏了什么?请帮我解决这个崩溃问题。

Can anyone please figure out if I am missing something? Please help me out in resolving this crash issue.

推荐答案

通常,完成处理程序不在主线程上运行。所有UI相关的东西必须在主线程上完成(包括解雇视图控制器)。

Usually completion handlers are not running on main thread. All UI related stuff must be done on main thread (including dismissing a view controller).

我建议在主线程块上添加这样的消除行:

I suggest to add the dismiss line on a main thread block like this:

-(void) showTouchIDAuthentication{

LAContext *myContext = [[LAContext alloc] init];
NSError *authError = nil;
NSString *myLocalizedReasonString = @"Authenticate using your finger to access My Account Menu.";
if ([myContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&authError]) {
    [myContext evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics
              localizedReason:myLocalizedReasonString
                        reply:^(BOOL success, NSError *error) {
                            if (success) {
                                NSLog(@"User is authenticated successfully");

                                [[NSOperationQueue mainQueue] addOperationWithBlock:^ {
                                    [self dismissViewControllerAnimated:YES completion:nil];
                                }];

                            } else {
   }];
    }

}

这篇关于iPhone App崩溃错误[UIApplication _cachedSystemAnimationFenceCreatingIfNecessary:]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆