九宫格中文键盘包含➋➌➍➎➏➐➑➒
解决:
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{
//获取高亮部分,在
//UITextRange *selectedRange = [textView markedTextRange];
//NSString * newText = [textView textInRange:selectedRange];
NSString *other = @"➋➌➍➎➏➐➑➒";
if([other rangeOfString:text].location != NSNotFound){
return YES;
}
//中文字符集
NSString *regex = @"[\u4e00-\u9fa5A-Za-z0-9]+";
NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",regex];
if ([pred evaluateWithObject:text] || [text isEqualToString:@""]) {
NSLog(@"输入的是中文字符和回退符号");
return YES;
}
if ([text isEqualToString:@"\n"]) {
[textView resignFirstResponder];
return NO;
}
NSLog(@"输入的不是中文,禁止输入");
return NO;
}