iOS UITextField get real-time monitor input, Chinese Pinyin character input state pre-removal

iOS UITextField get real-time monitor input, Chinese Pinyin character input state pre-removal

Real-time monitoring textField input content is not difficult, difficult is when Chinese input, Chinese Pinyin will now go. There are a bunch of characters, but also continue to increase. . . .

Solution:

- (void)viewDidLoad {
   [super viewDidLoad];

   UITextField *textField = [[UITextField alloc]initWithFrame:CGRectMake(100, 100, 100, 30)];
   [self.view addSubview:textField];
   [textField addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];

}
- (void)textFieldDidChange:(UITextField *)textField{
   if (textField.markedTextRange == nil) {
   NSLog(@"text:%@", textField.text);

   // code to be written, like in the inside
   }
}

Guess you like

Origin www.cnblogs.com/richard-youth/p/11505318.html