Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmatically changing keyboard type on iOS does nothing

I want to change keyboard type from default to numeric after user pressed return button. However after setting keyboardType property nothing happens.

My code:

-(BOOL)textFieldShouldReturn:(UITextField *)textField {     [textField setKeyboardType:UIKeyboardTypeNumbersAndPunctuation];      return YES; } 

I have set myself as text field delegate and the method is being called after pressing return button.

EDIT: Solved by

-(BOOL)textFieldShouldReturn:(UITextField *)textField {     [textField setKeyboardType:UIKeyboardTypeNumbersAndPunctuation];     [textField reloadInputViews];     return YES; } 
like image 648
Kladimir Avatar asked Sep 27 '12 10:09

Kladimir


People also ask

How can I change language of keyboard IOS programmatically?

No this is not possible - user can only change their language in the settings. You can change keyboard directly on the keyboard by pressing "globe icon" on the bottom row. First, you have to enable those language for input in Settings. Then pressing the globe button on the keyboard would toggle between those languages.

How do I change the keyboard language in IOS Swift?

Open Microsoft SwiftKey. Tap 'Languages' Ensure that both of your enabled languages have the a different layout selected (i.e QWERTY & AZERTY) Press and hold the spacebar and slide to choose your desired layout.


1 Answers

Try this:

-(BOOL)textFieldShouldReturn:(UITextField *)textField {     [textField setKeyboardType:UIKeyboardTypeNumbersAndPunctuation];     [textField reloadInputViews];     return YES; } 
like image 107
pro_metedor Avatar answered Sep 20 '22 02:09

pro_metedor