检查自定义键盘中 documentContextBeforeInput 中的字符
Check character in documentContextBeforeInput in Custom keyboard
///Here is my Function for Button press
@IBAction func keyPressed(_ button: UIButton) {
var buttonTap = button.titleLabel!.text
///Here i call a variable for Get before input in textDocumentProxy
var jukto = textDocumentProxy.documentContextBeforeInput
/// Now i want check if Three digits of documentContextBeforeInput is "ABC" Than it should change to "DE"
if jukto == "ABC" {
buttonTap = "DE"
}
(textDocumentProxy as UIKeyInput).insertText("\(buttonTap!)")
}
/// 注意:我的 documentContext 中会有很多字符,但我想检查 "ABC" 这 3 位数字是否在一起而不是更改。
@IBAction func keyPressed(_ button: UIButton) {
var buttonTap = button.titleLabel!.text
///Here i call a variable for Get before input in textDocumentProxy
var jukto = textDocumentProxy.documentContextBeforeInput
/// Now i want check if Three digits of documentContextBeforeInputis "ABC" Than it should change to "DE"
if jukto.range(of:"ABC") != nil{
buttonTap = "DE"
}
(textDocumentProxy as UIKeyInput).insertText("\(buttonTap!)")
}
///Here is my Function for Button press
@IBAction func keyPressed(_ button: UIButton) {
var buttonTap = button.titleLabel!.text
///Here i call a variable for Get before input in textDocumentProxy
var jukto = textDocumentProxy.documentContextBeforeInput
/// Now i want check if Three digits of documentContextBeforeInput is "ABC" Than it should change to "DE"
if jukto == "ABC" {
buttonTap = "DE"
}
(textDocumentProxy as UIKeyInput).insertText("\(buttonTap!)")
}
/// 注意:我的 documentContext 中会有很多字符,但我想检查 "ABC" 这 3 位数字是否在一起而不是更改。
@IBAction func keyPressed(_ button: UIButton) {
var buttonTap = button.titleLabel!.text
///Here i call a variable for Get before input in textDocumentProxy
var jukto = textDocumentProxy.documentContextBeforeInput
/// Now i want check if Three digits of documentContextBeforeInputis "ABC" Than it should change to "DE"
if jukto.range(of:"ABC") != nil{
buttonTap = "DE"
}
(textDocumentProxy as UIKeyInput).insertText("\(buttonTap!)")
}