iPhone 应用程序崩溃并出现错误 [UIApplication _cachedSystemAnimationFenceCreatingIfNecessary:] [英] iPhone App Crash with error [UIApplication _cachedSystemAnimationFenceCreatingIfNecessary:]

查看:17
本文介绍了iPhone 应用程序崩溃并出现错误 [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 deniedViewControllerAnimated:YES completion: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).

我建议像这样在主线程块上添加dismiss行:

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 应用程序崩溃并出现错误 [UIApplication _cachedSystemAnimationFenceCreatingIfNecessary:]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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