如何从Touch ID警报视图中删除“输入密码”和“取消”按钮
我卡住了,不想在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]; } }]; }
要隐藏“输入密码”按钮,需要将localizedFallbackTitle
设置为空字符串。
//... LAContext *context = [[LAContext alloc] init]; // Hide "Enter Password" button context.localizedFallbackTitle = @""; // show the authentication UI //...
关于“取消”按钮我不认为可以删除它。
希望它会有所帮助。
看看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;
。 让我们尝试一下,如果有效的话接受答案。
LAContext类有localizedFallbackTitle属性。 如果您想要自定义文本而不是“输入密码”,则可以在此处进行设置。
如果将其设置为空字符串,则该按钮将被隐藏。
以下是我用过的代码:
//MARK: - scanFingerPrint func scanFingerPrint() { let authContext:LAContext = LAContext() authContext.localizedFallbackTitle = "" . . . }
您可以删除“取消”按钮,但在这种情况下您的应用将被拒绝
[context setCancelButtonVisible:false];
看起来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