1

I am trying to get UITextField that on which the observer UIKeyboardDidShowNotification is being called.

My Observer is in appdelegate and I have several UIViewControllers that have several UITextFields in them, in short I don't know current First Responder.

How can I get the first responder inside my Method that is fired upon the keyboard notification UIKeyboardDidShowNotification?

2
  • If you only need to know what text field just got the focus, consider handling the UITextFieldTextDidBeginEditingNotification. It passes the text field in the object parameter. Commented Oct 6, 2015 at 12:55
  • do you need to make some changes on your project when UITextField called? Commented Oct 6, 2015 at 12:56

1 Answer 1

3

This is not possible to deduce from UIKeyboardDidShowNotification simply because it contains following information only. However, check this SO thread which has a brilliant solution on how to get the current first responder.

NSConcreteNotification 0x7ff14d1ac0d0 {name = UIKeyboardWillShowNotification; userInfo = { UIKeyboardAnimationCurveUserInfoKey = 7; UIKeyboardAnimationDurationUserInfoKey = "0.25"; UIKeyboardBoundsUserInfoKey = "NSRect: {{0, 0}, {320, 216}}"; UIKeyboardCenterBeginUserInfoKey = "NSPoint: {160, 676}"; UIKeyboardCenterEndUserInfoKey = "NSPoint: {160, 460}"; UIKeyboardFrameBeginUserInfoKey = "NSRect: {{0, 568}, {320, 216}}"; UIKeyboardFrameEndUserInfoKey = "NSRect: {{0, 352}, {320, 216}}"; UIKeyboardIsLocalUserInfoKey = 1; }}

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.