Как удалить кнопку "Ввести пароль" и "Отмена" в окне "Просмотр предупреждений"
Я застрял, чтобы не хотелось вводить пароль в сообщении с предупреждением большого пальца.
[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];
}
}];
}
Ответы
Ответ 1
Чтобы скрыть кнопку "Ввести пароль", вам нужно установить localizedFallbackTitle
в пустую строку.
//...
LAContext *context = [[LAContext alloc] init];
// Hide "Enter Password" button
context.localizedFallbackTitle = @"";
// show the authentication UI
//...
О кнопке "Отмена" я не думаю, что ее можно удалить.
Надеюсь, что это будет полезно.
Ответ 2
Существует localizedFallbackTitle свойство класса LAContext. Если вы хотите пользовательский текст вместо "Введите пароль", вы можете установить здесь.
Если для него задана пустая строка, кнопка будет скрыта.
![Screenshot 1]()
Ниже приведен код, который я использовал:
//MARK: - scanFingerPrint
func scanFingerPrint() {
let authContext:LAContext = LAContext()
authContext.localizedFallbackTitle = ""
. . .
}
![Screenshot 2]()
Ответ 3
Посмотрите 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;
. Попробуйте его и примите ответ, если он работает.
Ответ 4
Вы можете удалить кнопку "отменить", однако ваше приложение будет отклонено в этом случае
[context setCancelButtonVisible:false];
Ответ 5
Похоже, что 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