Hi I was taking care of one UITextField easily. e.g., Set delegate of UITextField my view controller and implement such method:
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
// Removes the keyboard from the screen
[self.textFieldProperty1 resignFirstResponder];
return YES;
}
But what if I have two UITextFields? A delegate for both of them will still be my view controller. And how do I implement the above method then? Like this?
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
// Removes the keyboard from the screen
[self.textFieldProperty1 resignFirstResponder];
[self.textFieldProperty2 resignFirstResponder];
return YES;
}
change your method as you pass the delegate to your property it will automatically identify from which textField method is called:
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
// Removes the keyboard from the screen
[textField resignFirstResponder];
return YES;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With