ios – LAContext更改UIAlertController按钮标题

前端之家收集整理的这篇文章主要介绍了ios – LAContext更改UIAlertController按钮标题前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我已经使用LAContext将TouchID合并到我的应用程序中,如下所示:

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

如何更改按钮标题

这是LAContext documentation,这是我的代码

  1. var touchIDContext = LAContext()
  2.  
  3. if touchIDContext.canEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics,error: &msgError) {
  4. touchIDContext.evaluatePolicy(.DeviceOwnerAuthenticationWithBiometrics,localizedReason: touchIDMessage) {
  5. (success: Bool,error: NSError!) -> Void in
  6.  
  7. if success {
  8. println("Success")
  9. } else {
  10. println("Error: \(error)")
  11. }
  12. }
  13. }

解决方法

设置localizedFallbackTitle属性

Objective-C的:

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

迅速:

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

猜你在找的iOS相关文章