first-responder

What is a formal definition of a first responder in iOS?

好久不见. 提交于 2019-12-03 00:15:24
I understand that a first responder object is the receives a callback signal according to input activity, etc and that it will bubble it up the chain until a responder willing to handle it can be found. But more formally, what is the scope of the first responder? For instance, is it an application-wide responder? It seems like being a first responder is simply saying that this particular object will receive notification of interaction. Can another responder steal the first responder status? Please explain or direct me to some pertinent information. I've read Apple's general explanation of what

Attempt to delete row containing first responder that refused to resign

坚强是说给别人听的谎言 提交于 2019-12-01 05:53:55
I have an iOS 6-based project that implements a UITableView . Each cell in the table view contains a UITextField allowing the user to enter information. If the user clears a text field, or deletes all input from the field, (i.e. [textfield length] == 0 ) when they tap onto another cell (text field) it deletes the previous cell (text field) from the table view, as it's empty - this avoids empty cells accumulating in the table view. This is all done using a method called -textFieldEditingDidEnd: which fires on the UIControlEventEditingDidEnd event for the text fields: - (void

Attempt to delete row containing first responder that refused to resign

丶灬走出姿态 提交于 2019-12-01 03:43:56
问题 I have an iOS 6-based project that implements a UITableView . Each cell in the table view contains a UITextField allowing the user to enter information. If the user clears a text field, or deletes all input from the field, (i.e. [textfield length] == 0 ) when they tap onto another cell (text field) it deletes the previous cell (text field) from the table view, as it's empty - this avoids empty cells accumulating in the table view. This is all done using a method called -textFieldEditingDidEnd

Find View that is the firstresponder

◇◆丶佛笑我妖孽 提交于 2019-11-30 13:37:34
I would like to get the view that is the first responder, currently I have a UITableView that contains UITextFields, using a method: -(UIView*) findFirstResponder { } I would like to be able to get the view that is the firstResponder and then do something with that view. Any ideas? All I had to do was @implementation UIView (FindViewThatIsFirstResponder) - (UIView *)findViewThatIsFirstResponder { if (self.isFirstResponder) { return self; } for (UIView *subView in self.subviews) { UIView *firstResponder = [subView findViewThatIsFirstResponder]; if (firstResponder != nil) { return firstResponder

Keyboard Animation Issues When Calling becomeFirstResponder within a Modal View Controller

风流意气都作罢 提交于 2019-11-30 06:28:46
问题 I've been having some issues with calling -becomeFirstResponder on a UITextField contained with a view controller that is presented modally. I call this method in the modal view controller's -viewDidLoad method so that the keyboard is immediately displayed. What I expected is for both the keyboard and the modal view controller to animate from up the bottom of the screen at the same time. However, what I'm observing is the following: There is a ~0.2 second UI lag between clicking the button

Change UITextField background when editing begins

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-30 05:19:11
I'd like to change the background image of a UITextField when it becomes the firstResponder to show the user that it has focus, similar to the :active or :focus pseudo-classes in CSS. I'm guessing that I may need to do this programmatically; so any help is greatly appreciated. -Giles You might as well use the UITextFieldDelegate methods (IMHO, easier to maintain than key-value observers): #pragma mark - #pragma mark UITextFieldDelegate methods - (BOOL)textFieldShouldBeginEditing:(UITextField *)textField { _field.background = [UIImage imageNamed:@"focus.png"]; return YES; } - (BOOL

iOS unit test: How to set/update/examine firstResponder?

无人久伴 提交于 2019-11-30 04:51:34
How do you write first responder unit tests? I'm trying to write a test to confirm that a method advances focus to the next text field. controller is a descendant of UIViewController . But this exploratory test fails: - (void)testFirstResponder { [controller view]; [[controller firstTextField] becomeFirstResponder]; STAssertTrue([[controller firstTextField] isFirstResponder], nil); } The first line causes the view to be loaded so that its outlets are in place. The text fields are non-nil. But the test never passes. I'm guessing that becomeFirstResponder doesn't set the first responder right

hitTest fires when UIKeyboard is tapped

回眸只為那壹抹淺笑 提交于 2019-11-30 04:36:24
问题 I'm trying to fix a bug that involves UIView hitTest:withEvent: being called on my view when the touches are on the UIKeyboard, but only after the app has been in the background. It was occurring in my app with a complex view hierarchy so I reproduced it in an app with only 2 views: 1 UIView 768x1024 (fullscreen) 1 UITextView 200x200 in the upper half of the fullscreen view The behavior is as follows: Tapping the textview causes the fullscreen view's hitTest method to fire, the textfield

Custom inputView for UITextField , how do I direct input back to the text field?

可紊 提交于 2019-11-30 02:07:22
I have set a custom inputView to my UITextField . I need a way to display the data selected in my custom inputView in the UITextfield . I would like to achieve this the same way the system keyboard does it. Does anyone know how this is done? How does the system keyboard get a reference to the UITextfield that is the first responder? How does the system keyboard get a reference to the UITextfield that is the first responder? It just asks the system for the first responder; unfortunately, that's a private UIKit method (or was, last I checked). You can find the first responder by recursing

How to activate next UITextField in a UITableView?

梦想的初衷 提交于 2019-11-30 00:32:51
I am using this other SO answer for adding UITextField s to my UITableViewCell s. However, I am now at a loss how I can let the user focus on the next item by using the next button. Any hints? Anh Do Try assigning a tag to each UITextField. Once the Next button is pressed, calculate the next tag and use [[UIView viewWithTag:nextTag] becomeFirstResponder] to change the focus to the next text field. This worked well for me, would have to be tweaked to fit your needs though: #pragma mark - UITextField Delegate - (BOOL)textFieldShouldReturn:(UITextField *)textField { HRCFormCell * currentCell =