Ich habe den folgenden Code, der auf dem iPad erfolgreich ausgeführt wird.Benutzerdefinierte Tastatur auf IOS mit Schaltflächen Bilder anzeigen
func setupLockPinSection() {
let keys = ["1", "2","3", "4","5", "6","7", "8","9", "0", "Clear", "Done"]
let kbFrame = CGRect(x: 0, y: 0, width: view.frame.width, height: 400)
if let customKeyboard = Bundle.main.loadNibNamed("MACustomKeyboard", owner: self, options: nil)?.first as? MACustomKeyboard {
customKeyboard.frame = kbFrame
customKeyboard.setKeyboardButtons(keys)
lockPin1.inputView = customKeyboard
//Number Tapped
customKeyboard.numberTappedBlock = { [weak self] view, text in
if let textFieldText = self?.lockPin1.text, let t = text {
self?.lockPin1.text = textFieldText + t
}
}
//Done button Tapped
customKeyboard.doneTappedBlock = { [weak self] view in
self?.lockPin1.resignFirstResponder()
}
//Clear Button Tapped
customKeyboard.clearTappedBlock = { [weak self] view in
if let text = self?.lockPin1.text, text.characters.count > 0 {
self?.lockPin1.text = text.substring(to: text.index(text.endIndex, offsetBy: -1))
}
}
}
if let customKeyboard = Bundle.main.loadNibNamed("MACustomKeyboard", owner: self, options: nil)?.first as? MACustomKeyboard {
customKeyboard.frame = kbFrame
customKeyboard.setKeyboardButtons(keys)
lockPin2.inputView = customKeyboard
//Number Tapped
customKeyboard.numberTappedBlock = { [weak self] view, text in
if let textFieldText = self?.lockPin2.text, let t = text {
self?.lockPin2.text = textFieldText + t
}
}
//Done button Tapped
customKeyboard.doneTappedBlock = { [weak self] view in
self?.lockPin2.resignFirstResponder()
}
//Clear Button Tapped
customKeyboard.clearTappedBlock = { [weak self] view in
if let text = self?.lockPin2.text, text.characters.count > 0 {
self?.lockPin2.text = text.substring(to: text.index(text.endIndex, offsetBy: -1))
}
}
}
lockPin1.text = UserDefaults.standard.string(forKey: "lockPin")
lockPin2.text = UserDefaults.standard.string(forKey: "lockPin")
}
Ich mag die klare und done Taste wie die, die auf iOS Standard-Tastatur mit den Anzeigen von Bildern (versteckten Tastatur-Taste, Löschtaste) machen. Ich möchte dies tun, weil ich für meine Lock-Pin-Funktionalität nur Ziffern verwenden möchte, und auf dem iPad erlaubt das nicht. Daher muss ich es angepasst Tastatur machen.
Also, was ist dein Problem? :) – d4Rk
@ d4Rk, ich habe gerade nach Problem unten in weiteren Details mit Bildern geschrieben. Wenn Sie es bitte sehen könnten, schlagen Sie mir eine Lösung vor. Geschätzt. – habed