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
Just to update the great answers above for anyone facing the same issues as me:
This is how we did it:
func textField(textField: UITextField, shouldChangeCharactersInRange range: NSRange, replacementString string: String) -> Bool {
if !string.canBeConvertedToEncoding(NSASCIIStringEncoding){
return false
}
//other conditons
}
Edit
Okay the solution with NSASCIIStringEncoding is no good if you want to allow certain characters for other languages.
Some letters blocked with NSASCIIStringEncoding:
Using NSASCIIStringEncoding is not a good idea if you want to support users from other countries!
I also tried NSISOLatin1StringEncoding:
This is much better clearly.
I also tried NSISOLatin2StringEncoding:
Worse.
Edit2:
The following seems to work:
extension String {
func containsEmoji() -> Bool {
for i in self.characters {
if i.isEmoji() {
return true
}
}
return false
}
}
extension Character {
func isEmoji() -> Bool {
return Character(UnicodeScalar(0x1d000)) <= self && self <= Character(UnicodeScalar(0x1f77f))
|| Character(UnicodeScalar(0x1f900)) <= self && self <= Character(UnicodeScalar(0x1f9ff))
|| Character(UnicodeScalar(0x2100)) <= self && self <= Character(UnicodeScalar(0x26ff))
}
}
Now we call:
func textField(textField: UITextField, shouldChangeCharactersInRange range: NSRange, replacementString string: String) -> Bool {
if string.containsEmoji() {
return false
}
//other conditons
}