27

我被卡住了,不想在拇指印象警报中输入密码

[context evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason:NSLocalizedString(@"UNLOCK_ACCESS_TO_LOCKED_FEATURE", nil) reply:
         ^(BOOL success, NSError *authenticationError)
         {
             if (success)
             {

                 msg =[NSString stringWithFormat:NSLocalizedString(@"EVALUATE_POLICY_SUCCESS", nil)];
             }
             else
             {
                 msg = [NSString stringWithFormat:NSLocalizedString(@"EVALUATE_POLICY_WITH_ERROR", nil), authenticationError.localizedDescription];
             }
         }];
     }
4

7 回答 7

70

To hide the button "Enter password", you need to set localizedFallbackTitle to an empty string.

//...
LAContext *context = [[LAContext alloc] init];

// Hide "Enter Password" button
context.localizedFallbackTitle = @"";

// show the authentication UI
//...

About the "Cancel" button I don't think that it is possible to remove it.

Hope that it will be helpful.

于 2015-01-26T18:08:30.223 回答
13

LAContext类有localizedFallbackTitle属性。如果您想要自定义文本而不是“输入密码”,那么您可以在此处设置。

如果将其设置为空字符串,则该按钮将被隐藏。

截图 1

下面是我使用过的代码:

 //MARK: - scanFingerPrint
    func scanFingerPrint() {
        let authContext:LAContext = LAContext()
        authContext.localizedFallbackTitle = ""
    . . .
    }

截图 2

于 2016-09-14T11:19:01.100 回答
4

看看LAContext.h,我发现了这个:

/// Fallback button title.
/// @discussion Allows fallback button title customization. A default title "Enter Password" is used when
///             this property is left nil. If set to empty string, the button will be hidden.
@property (nonatomic, copy) NSString *localizedFallbackTitle;

你应该设置localizedFallbackTitle = @"" -- empty string;. 让我们尝试一下,如果它有效,请接受答案。

于 2015-01-23T07:08:31.317 回答
1

您应该使用像 "" 这样的空字符串作为本地化的FallbackTitle
示例:

let context:LAContext = LAContext()
context.localizedFallbackTitle = ""
于 2021-09-09T07:44:21.337 回答
0

您可以删除“取消”按钮,但在这种情况下您的应用将被拒绝

[context setCancelButtonVisible:false];
于 2015-02-12T11:21:52.047 回答
0

看起来 Apple 添加了一种方法来自定义 iOS 10 中的取消按钮标题,

localizedCancelTitle

The localized title for the fallback button in the dialog presented to the user during authentication.

Discussion

This string should be provided in the user’s current language and should be short and clear.

https://developer.apple.com/documentation/localauthentication/lacontext/1643658-localizedcanceltitle

于 2018-01-24T09:52:36.177 回答
0

如果您愿意,可以更改取消按钮的标题

[context setLocalizedCancelTitle:@"ABC"];
于 2021-01-05T15:43:31.297 回答