How to disable iOS 8 emoji keyboard?

前端 未结 12 2161
说谎
说谎 2020-12-03 00:33

Is there any option to stop showing the emoji keyboard in iOS 8? It is not available in numpad and secure text but for email it is there. If it is not possible to disable i

12条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-03 01:13

    The solution that worked for me :

    self.texField.keyboardType = UIKeyboardTypeASCIICapable;
    

    The emoji keyboard won't be available with that KeyboardType.

    But it's compulsory to check the kind of every char added in the textField, because the user can copy an emoji from elsewhere then paste it in.

    Here is how you could do so :

    - (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text {
         return [text canBeConvertedToEncoding:NSASCIIStringEncoding];
    }
    

    Be warned that, as I read in another post, this might also prevent user from using keyboard with special characters, like the Chinese one.

提交回复
热议问题