Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the "force" parameter do in UIView.endEditing?

Tags:

ios

swift

In what situation will self.view.endEditing(true) and self.view.endEditing(false) produce different results?


The docs for func endEditing(force: Bool) -> Bool state the following for the parameter force:

Specify true to force the first responder to resign, regardless of whether it wants to do so.

like image 298
Code Avatar asked Feb 23 '16 09:02

Code


1 Answers

As the comment mentioned, if canResignFirstResponder returns false, self.view.endEditing(true) will cause the control to lose focus but self.view.endEditing(false) will not.

like image 124
Code Avatar answered Oct 23 '22 01:10

Code