Code Code - 2 years ago 72
Swift Question

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

In what situation will

produce different results?

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

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

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download