Here is my Sample Code:
class ViewController: UIViewController, UITextViewDelegate {
@IBOutlet weak var textView_editingView: UITextView!
override func viewDidLoad() {
super.viewDidLoad()
textView_editingView.text = ""
textView_editingView.delegate = self
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool {
print("Not Called")
return true
}
func textViewDidChange(_ textView: UITextView) {
print("Called")
}
}
When I change keyboard type to "Chinese (Simplified) - Handwriting", "shouldChangeTextIn range" (UITextViewDelegate) isn't called while entering a text.
There are certain check in this delegate which needs to be called like mention, hashtags, urls. Since this delegate is not called, so my logic for these validations fails when keyboard is changed. Otherwise, everything works fine for a normal English keyboard.
Please Note: I am using the default keyboard which are available in XCode Simulator's Keyboard setting, and this is also reproducible on iPhone 7 Plus.