Search code examples
iosxcodeuitextfieldemojiuikeyboardtype

iOS Email Keyboard has Emoji button, can this be disabled?


When setting the keyboard in IB or programatically as below for a UITextField.

[textFieldOutlet setKeyboardType:UIKeyboardTypeEmailAddress];

The keyboard has an Emoji icon which means you can type in Emoji's in an email address (which is a bit rubbish). Can this be disabled? I understand I can change the type to ASCIICapable but then I do not have the easy access to @ and . signs.

I have worked around it with this which just stops the Emoji being entered but the button is still there (Credit Here with MeganZhou answer).

- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
    if ([textField isFirstResponder])
    {
        if ([[[textField textInputMode] primaryLanguage] isEqualToString:@"emoji"] || ![[textField textInputMode] primaryLanguage])
        {
            return NO;
        }
    }

    return YES;
}

I have also noted that the icon is there when you are typing an email address in Mail too.

This is iOS8 but may also be in earlier version.


Solution

  • User have to follow below steps if he wants to get rid of emoji button.

    • Settings---> General ---> keyboard-----> Keyboards---> You'll see ENGLISH and EMOJI.
    • On the top right corner is the word EDIT.
    • Press EDIT, and then swipe delete to remove the EMOJI keyboard.

    This will remove the emoji button and user can also have easy access to @ and . signs.

    Note:- For security reasons, iOS does not allow programmers to remove keyboard programatically.