How to remove Enter Password and Cancel button from Touch ID alert view

泄露秘密 提交于 2019-12-03 22:21:39

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.

There is localizedFallbackTitle property of LAContext class. If you want custom text instead of “Enter password” then you can set here.

If it is set to empty string then the button will be hidden.

Below is code that I’ve used :

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

Look at LAContext.h, I found this:

/// 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;

You should set localizedFallbackTitle = @"" -- empty string;. Let's try it and accept answer if it work.

You can remove "cancel" button, however your app will be rejected in this case

[context setCancelButtonVisible:false];

Looks like Apple has added a way to cusotmize the cancel button title from 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!