Bug resolution record on iOS default Chinese Input Method garbled, iosbug
When I write a Blog for the first time, I will record a problem that occurred in the project today.
In a text box, convert it to a Chinese input method, and then start the input,
Click "Post" and submit the data to the background. The result is displayed? Garbled issues, such:
This problem plagued me for a while. Later I found that when I entered Chinese, it seemed to be selected. when I switched the focus, the input box would convert the input to English, so I thought about canceling the selected solution when I click "Post", and record it here, so that I don't know how to deal with the same problem in the future:
UITextRange * textRange = [self. textView textRangeFromPosition: self. textView. Adjust toPosition: self. textView. beginningOfDocument]; [self. textView setSelectedTextRange: textRange]; [self. textView details];
Directly use UITextRange to set the cursor to the initial position. In this way, the text box will automatically convert the unfinished Chinese characters into English and write them into the text box.