LAContext 更改 UIAlertController 按钮标题

7
我使用LAContext将TouchID集成到我的应用程序中,就像这样:

enter image description here

然而,我想将按钮标题从“输入密码”更改为“输入安全码”(或类似内容),就像这样:

enter image description here

如何更改该按钮标题?
这是LAContext文档,这是我的代码:
var touchIDContext = LAContext()

if touchIDContext.canEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, error: &msgError) {
   touchIDContext.evaluatePolicy(.DeviceOwnerAuthenticationWithBiometrics, localizedReason: touchIDMessage) {
        (success: Bool, error: NSError!) -> Void in

        if success {
            println("Success")
        } else {
            println("Error: \(error)")
        }
    }
}

我的回答对你有用吗? - Paul Cezanne
1
是的,没错。我把你的答案设为正确。 - Cody Winton
@Cody 你好,能否分享一下如何将警报标题“Touch ID”更改为“Touch ID for "XXXX"”? - S P Balu Kommuri
2个回答

12

设置localizedFallbackTitle属性:

Objective-C:

LAContext *context = [[LAContext alloc] init];
context.localizedFallbackTitle = @"YOUR TEXT HERE";

Swift:

var touchIDContext = LAContext()
context.localizedFallbackTitle = "YOUR TEXT HERE"

好的回答...我一直在想如何更改Touch ID警报的标题。例如 "Touch ID for ********* ",我的文本放在*******处。 - iAnurag
无论如何,我得到了答案。不管怎样,还是谢谢。 - iAnurag
1
@iAnurag:你的问题的答案是什么? - Shreesh Garg
你好,能否请您分享一下如何将警报标题“Touch ID”更改为“Touch ID for 'XXXX'”? - S P Balu Kommuri
1
@Balu - “XXXX”是从您的info.plist中的应用程序名称自动填充的。 - Cody Winton

2

根据苹果文档,localizedCancelTitle 仅适用于 iOS 10。

// 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, nullable, copy) NSString *localizedFallbackTitle;

// Cancel button title.
// @discussion Allows cancel button title customization. A default title "Cancel" is used when
//             this property is left nil or is set to empty string.
@property (nonatomic, nullable, copy) NSString *localizedCancelTitle NS_AVAILABLE(10_12, 10_0);

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接