2015-01-22 19 views
6

tôi đã kết hợp TouchID vào ứng dụng của tôi với LAContext, như vậy:LAContext thay đổi UIAlertController nút tiêu đề

enter image description here

Tuy nhiên, tôi muốn thay đổi tên của tiêu đề nút từ "Nhập mật khẩu" nhập "nhập Mã bảo vệ" (hoặc một cái gì đó như thế), như thế này:

enter image description here

Làm thế nào tôi sẽ đi về việc thay đổi mà tiêu đề nút?

Đây là LAContextdocumentation và đây là mã của tôi:

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

Câu trả lời của tôi có phù hợp với bạn không? –

+1

Yup, nó đã làm. Tôi đặt câu trả lời của bạn là chính xác. –

+0

@ Xin chào bạn có thể chia sẻ cách bạn thay đổi tiêu đề cảnh báo "Touch ID" thành "Touch ID cho" XXXX "" – Balu

Trả lời

11

Thiết lập thuộc tính localizedFallbackTitle:

Objective-C:

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

Swift:

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

câu trả lời hay ... tôi đã tự hỏi làm thế nào để thay đổi Tiêu đề cho cảnh báo id cảm ứng. ví dụ: "ID cảm ứng cho *********". văn bản của tôi đi vào *******. – iAnurag

+0

@iAnurag - gửi câu hỏi lên đó. (Và nó cũng không rõ ràng những gì bạn có nghĩa là ... –

+0

anyway .. Tôi có câu trả lời.Cảm ơn anyway – iAnurag

0

Từ Tài liệu Apple, localizedCancelTitle có sẵn cho 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); 
Các vấn đề liên quan