dismiss modal view with return key
-
26-09-2019 - |
Question
I got one UITextField on my Modal view controller. When "Done" key is clicked, i want to dismiss the modal view. i don't know where should i add below code to dismiss modal view. Thanks in advance for any help.
[self.parentViewController dismissModalViewControllerAnimated:YES];
Solution
add it in UITextFieldDelegate
method
-(BOOL)textFieldShouldReturn:(UITextField *)textField {
[textField resignFirstResponder];
[self.parentViewController dismissModalViewControllerAnimated:YES];
return YES;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow