I have a UIView
with a UITextView
and UITextField
as a subview. I want the keyboard to appear automatically on textFieldShouldReturn
call.
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
[textField resignFirstResponder];
[textView becomeFirstResponder];
return YES;
}
but this does not work AND for some reason, it displays keyboard with cursor on next line in text view . I tried to set text nil in textview but it automatically call textDidChange
method and cursor moves on new line without any text.
This same technique works correctly for a UITextField
and also it works fine with iOS 5.0 but how to fix this in iOS 4.3. Let me know if you have any alternative as well.
Am I missing something obvious?
There's a known bug in iOS with resigning and becoming first responder within the same runloop. Try the following
[textField resignFirstResponder];
[textView performSelector:@selector(becomeFirstResponder) withObject:nil afterDelay:0.0];
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