LAContext更改UIAlertController按钮标题

时间:2015-01-22 17:56:01

标签: ios swift uialertcontroller touch-id

我已使用LAContext将TouchID合并到我的应用中,如下所示:

enter image description here

但是,我想要从“输入密码”更改按钮标题的名称,进入“输入安全码”(或类似的东西),如下所示:

enter image description here

如何更改该按钮标题?

以下是LAContext documentation,这是我的代码:

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)")
        }
    }
}

2 个答案:

答案 0 :(得分:12)

设置localizedFallbackTitle属性:

目标-C:

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

夫特:

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

答案 1 :(得分:2)

从Apple文档中,{10}可用于iOS 10

localizedCancelTitle