【问题标题】:iPhone App Crash with error [UIApplication _cachedSystemAnimationFenceCreatingIfNecessary:]iPhone 应用程序崩溃并出现错误 [UIApplication _cachedSystemAnimationFenceCreatingIfNecessary:]
【发布时间】:2017-02-03 08:29:41
【问题描述】:

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

IOS 10.1 发布后,当我查看崩溃报告时,崩溃计数增加了。从崩溃报告中,它指向[UIApplication _cachedSystemAnimationFenceCreatingIfNecessary:],当我在Xcode中打开应用程序时,它集中在[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 中进行测试时,一切正常。不知道如何模拟问题。

谁能帮我弄清楚我是否遗漏了什么?请帮我解决这个崩溃问题。

【问题讨论】:

    标签: iphone uiviewcontroller objective-c-blocks touch-id


    【解决方案1】:

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

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

    -(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 {
       }];
        }
    
    }
    

    【讨论】:

    • 感谢您的帮助 Fidel ...实际上这是一个奇怪的问题,每当我进行测试时,该问题都没有得到重现,并且一切正常。
    猜你喜欢
    • 1970-01-01
    • 2019-06-04
    • 2017-09-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-24
    相关资源
    最近更新 更多