[英]How to remove Enter Password and Cancel button from Touch ID alert view
我被卡住了,不想在拇指印象警報中輸入密碼
[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;
. 讓我們嘗試一下,如果有效,請接受答案。
您可以刪除“取消”按鈕,但是在這種情況下您的應用程序將被拒絕
[context setCancelButtonVisible:false];
看起來蘋果已經添加了一種方法來自定義 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
如果您願意,您可以更改取消按鈕的標題
[context setLocalizedCancelTitle:@"ABC"];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.