如何从Touch ID警报视图中删除“输入密码”和“取消”按钮

时间:2015-01-23 05:27:16

标签: ios uialertview lacontext

我卡住了,不想在Thumb of thumb impression中输入密码

[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];
             }
         }];
     }

6 个答案:

答案 0 :(得分:58)

要隐藏按钮"输入密码",您需要将localizedFallbackTitle设置为空字符串。

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

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

// show the authentication UI
//...

关于"取消"按钮我不认为可以删除它。

希望它会有所帮助。

答案 1 :(得分:8)

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

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

Screenshot 1

以下是我用过的代码:

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

Screenshot 2

答案 2 :(得分: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;。如果有效,我们试试并接受答案。

答案 3 :(得分:0)

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

[context setCancelButtonVisible:false];

答案 4 :(得分: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

答案 5 :(得分:0)

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

[context setLocalizedCancelTitle:@"ABC"];