1

I just started to suspect that calling resignFirstResponder directly is not actually allowed. Unlike NSResponder, it's allowed to call becomeFirstResponder directly in UIKit. So far I was making assumption that calling resignFirstResponder would be okay too. But in fact, the manual says resignFirstResponder method is there to get notified, and mentions nothing about direct calling.

Notifies this object that it has been asked to relinquish its status as first responder in its window.

If it's designed in same way of how NSResponder works, direct calling to resignFirstResponder wouldn't be allowed though there's no obvious way to figure out validity of the call in the manual...

If it's been designed not to be called directly, directly calling to the method would be harmful or make code harder to maintain.

Is it okay to call UIResponder.resignFirstResponder method directly?

eonil
  • 83,476
  • 81
  • 317
  • 516

1 Answers1

0

It seems to be okay because on another part of the manual, it says

... To dismiss the keyboard, you call the resignFirstResponder method of the text-based view that is currently the first responder. When a text view resigns its first responder status, it ends its current editing session, notifies its delegate of that fact, and dismisses the keyboard. In other words, if you have a variable called myTextField that points to the UITextField object that is currently the first responder, dismissing the keyboard is as simple as doing the following:

[myTextField resignFirstResponder];

Everything from that point on is handled for you automatically by the text object.

eonil
  • 83,476
  • 81
  • 317
  • 516