在不知道第一响应者的情况下取消键盘方法
很多的时候,我们需要取消键盘,但是又不知道键盘的第一响应者,那么怎么办呢,那么可以通过一下方法解决:
[[UIApplicationsharedApplication] sendAction:@selector(resignFirstResponder)to:nil from:nil forEvent:nil];
官方文档有说明:
The object to receive the action message. If target
is nil
,
the app sends the message to the first responder, from whence it progresses up the responder chain until it is handled.