7

In my view controller's -viewDidLoad method, I call [myTextField becomeFirstResponder]; This works like a charm, opens the keyboard and myTextField gets focus.

I have a button with a target action (the action is in the same controller) that checks [myTextField isFirstReponder] - but it always returns false (er, NO in Cocoa terms ;)).

Is that not the right way to find out if myTextField has the keyboard up for input?

Chris Hanson
  • 54,380
  • 8
  • 73
  • 102
RickDT
  • 2,104
  • 1
  • 23
  • 25

1 Answers1

14

What about checking the value of the editing property, ie [myTextField isEditing]?

I think your button takes over first responder status when you tap it.

Jablair
  • 5,036
  • 4
  • 28
  • 37
  • 2
    That's exactly it. Clicking the button takes focus and technically I want to know which is currently editing, not necessarily if the window considers it first reponder. Thanks! – RickDT Oct 31 '08 at 11:25
  • 2
    This works, sure. But why isn't the `isFirstReponder`working? No one curious? – lukas_o Dec 04 '15 at 14:53
  • 7
    this doesn't work for me. even though the text field is clearly being edited, `isFirstResponder` and `isEditing` both return false – shoe Apr 06 '17 at 06:51