输入框不允许输入Emoji表情

在开发过程中,由于各种问题很可能会出现这种需求:
输入框不允许输入emoji表情

- (BOOL)textView:(UITextView )textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString)text
{
//不允许输入emoji表情
if ([textView isFirstResponder])
{
if ([[[textView textInputMode] primaryLanguage] isEqualToString:@"emoji"] || ![[textView textInputMode] primaryLanguage])
{
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
hud.mode = MBProgressHUDModeText;
hud.label.text = @"评论不支持输入emoji表情";
[hud hideAnimated:YES afterDelay:1.f];
return NO;
}
}
return YES;
}

你可能感兴趣的:(输入框不允许输入Emoji表情)