There is an application in which I am generating multiple UITextFields
dynamically. I want to resign first responder whenever the UITextFields
are not selected (touch outside the UITextField
). How can I know that of which UITextField
I have to resign first responder? Please specify any other way beyond the 'tag' concept because I have tried that. Please suggest the right direction. Thanks in advance.
相关问题
- CALayer - backgroundColor flipped?
- Core Data lightweight migration crashes after App
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- State preservation and restoration strategies with
相关文章
- 现在使用swift开发ios应用好还是swift?
- UITableView dragging distance with UIRefreshContro
- Could I create “Call” button in HTML 5 IPhone appl
- TCC __TCCAccessRequest_block_invoke
- Where does a host app handle NSExtensionContext#co
- Unable to process app at this time due to a genera
- Swift - hide pickerView after value selected
- How do you detect key up / key down events from a
You can set
textFields
as properties and synthesize them. You will need as many properties as you are using in your app.You can have
@synthesise myTextField0, myTextField1, myTextField2;
for three textFields. Just assign eachUITextField
you are using to these properties, while declaring them.And when you want to resign them, just use
[self.myTextField0 resignFirstResponder]
attextFieldDidEndEditing
or which ever function you want to resign them. And you can use this for other textFields also. This is the way to handle multiple textFieldsIn general, you can skip all these steps, with
textField.returnKeyType = UIReturnKeyDone;
if you have aDONE
return key, you can just go to the methodor you can use
tags
to tag certain textFields and then resign particular ones.Using
[self.view endEditing:YES];
to resignFirstResponder for the current active UITextField.You can use
endEditing
instead ofresignFirstResponder
Try This
By the way..i have done this in different manner.. Not looking quite a good programming Champ tech but enough to solve my work!!
You can implement delegate method
in that you can take currentTextField = textField;
in another delegate method
you can do currentTextField = nil;
you can then resign currentTextField....