In iOS 7, I could change the keyboard type while it is the firstResponder
(on the fly):
if (textField.text.length > 2) {
textField.keyboardType = UIKeyboardTypeNumbersAndPunctuation;
}
else
{
textField.keyboardType = UIKeyboardTypeDefault;
}
[textField reloadInputViews];
// (Omitting some efficiency stuff to keep example to bare bones)
This no longer works under Xcode 6/iOS 8. The documentations mostly reflect changes regarding custom keyboard.
Using resign/become first responder is (still) working:
[textField resignFirstResponder];
// Make keyboard change
[textField becomeFirstResponder];
But it just feels like an overkill. It's tearing and rebuilding a wall, just to change a picture on it.
There is a related post here: UITextView does not seem to implement reloadInputViews
But it seems that the solution (in a comment) is "apparently declaring it as a UITextView instead of a UIResponder affects how it behaves during runtime. ... and it works now"
In my case it is a UITextField
, and I tried to cast to UITextView
just in case. No go.
I'll mention again that it is working well under iOS7 / Xcode5.
I don't really know if this is a 'beta' issue with Xcode 6, or a design change in iOS 8.
I found that this works when the textfield is first responder:
[self.textField reloadInputViews];
[self.textField setText:@" "];
[self.textField setText:@""];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With