Search code examples
iphonexcodexcode4uitextfield

xcode 4.2.1 - custom keyboard - two UITextFields


I have created a custom keyboard and I have two text fields.

I am calling [firstTextField becomeFirstResponder] in my viewDidLoad

to have my keyboard visible.

How can I know which text field is currently active so that I write what the user is typing from the keyboard to the respected textField?

I have tried - (BOOL)textFieldShouldBeginEditing:(UITextField *)textField but it is not being called

any idea?


Solution

  • You should be able to use isFirstResponder to determine which of your two UITextFields is currently active.

    if ([firstTextField isFirstResponder]) {
        ...
    }
    else {
        ...
    }