做項(xiàng)目的時(shí)候需要用到UITextView
輸入法設(shè)置為中文時(shí)胸遇,我想輸入中文“有”,我輸入一個(gè)字母y的時(shí)候汉形,一下回調(diào)會(huì)被調(diào)用
-(BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
和
- (void)textViewDidChange:(UITextView *)textView
目前的解決方案是用以下方式做適配
-(BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{
if (textView.text.length !=0) {
int a = [text characterAtIndex:0];
if( a > 0x4e00 && a < 0x9fff)
{
NSLog(@"漢字");//做相應(yīng)適配
}
else
{
NSLog(@"english");//做相應(yīng)適配
}
}
returnYES;
}