If your subclass of UIViewController has the following:
- (BOOL)canBecomeFirstResponder { return YES; } - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; if (self.view.window) { [self becomeFirstResponder]; } }
then you probably intended to allow this subclass to handle motion events (shaking) or something similar. So thatโs probably why it is there.
If you were unable to edit the UITextField
, then this subclass probably became the first responder and did not redirect the event to the actual UITextField
. When a subclass of UIViewController
calls UIViewController
overrides to return YES
and makes it the first responder itself (ie [self becomeFirstResponder]
, if you want this user class to not handle touch events for UITextField
, you must override the nextResponder
method.
An example from my own product. Essentially, I have a subclass of UIViewController
that does two things: 1) it handles shaking events and 2) it displays a different view when some kind of button is used. UITextField
there are several UITextField
s. To allow my subclass of UIViewController
forward touch events to my modal view, I added the following:
- (UIResponder *)nextResponder { if (!self.view.window) { // If the modal view is being displayed, forward events to it. return self.modalViewController; } else { // Allow the superclass to handle event. return [super nextResponder]; } }
This will work on iOS 4 and 5 using sdk.
Now, in your case, you obviously donโt remember how to add code to become the first responder in the first place, so you do not need the aforementioned interceptors. However, this is good to know in the future.
Let's get back to your current question - as soon as you upgrade your SDK to 5, why not work on iOS 4, but they will work on iOS 5? iOS 5 does some event forwarding for you, so it works there. It should have never worked on iOS 4 at the beginning. Apple fixed some bugs that allowed it to work on 4, so it no longer works on 4.
I know that the question has already accepted the accepted answer; I just wanted to clear up any confusion.