【发布时间】:2017-07-20 12:11:55
【问题描述】:
///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位数字是否在一起而不是改变。
【问题讨论】:
标签: ios iphone swift swift2 custom-keyboard