2017-03-01 2 views
0
 ///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!)") 


    } 

/// Hinweis: Es wird viele Zeichen in meinem documentContext geben, aber ich möchte überprüfen, ob "ABC" diese 3 Ziffern zusammen ist, als es geändert wird.Zeichen in documentContextBeforeInput in Benutzerdefinierter Tastatur

Antwort

2
@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!)") 


} 
+0

Das funktioniert für mich. Vielen Dank :) –

Verwandte Themen