IOS ---------- UITextField implements filtering of selected pinyin characters,
On the second day of work on April 9, 2018, we carried a big pot. Our project has a search function. In this phase, in order to enhance the optimization, the request to filter spaces may be removed, which may improve the user experience. On the contrary, it is impossible to hack rice into a chicken. I didn't expect that the input method of the Apple system could be automatically associated. When I didn't select Chinese characters, I could think of a lot of smart pinyin. what ??? What else is this operation ???? I almost do not use the input method of the Apple system. my mobile phone settings usually Delete the input method of Apple and use sogou directly. (The input method of the Apple system is too difficult to use.) but for testers, you must test the input methods of each system. Remember! Remember! Remember!
Now let's take a look at the content that is not blocked before pinyin.
When I enter the blue ocean, the system automatically concatenates some pinyin characters without Selecting Chinese characters.
Are you surprised to compare the printed content? How can we remove pinyin? Add an event to the input box. You can try filtering out pinyin or not in the event.
_ SearchTextField = [[UITextField alloc] initWithFrame: CGRectMake (20,100, kScreenWidth-40, 50)];
_ SearchTextField. delegate = self;
_ SearchTextField. backgroundColor = [UIColor orangeColor];
_ SearchTextField. placeholder = @ "Enter funds and quickly locate ";
_ SearchTextField. returnKeyType = UIReturnKeyDone;
_ SearchTextField. clearButtonMode = UITextFieldViewModeWhileEditing;
[_ SearchTextField addTarget: self action: @ selector (searchTextFieldChanges :) forControlEvents: UIControlEventEditingChanged];
[Self. view addSubview: _ searchTextField];
-(Void) searchTextFieldChanges :( UITextField *) textField {
If (textField. markedTextRange = nil ){
NSLog (@ "Chinese characters displayed after Chinese characters are selected: % @", textField. text );
}
}