I have a custom View (NotifyView
) added on UIWindow
with a dismiss button(which remove it from UIWindow
).
This view is added when a PUSH notification comes in didReceiveRemoteNotification
there are several cases when I could be on any screen, and my keyboard is UP via UITextfield
/UITextview
.
At this stage if a push comes, the NotifyView
is added on UIWindow
behind the keyboard.
I want to resign the keyboard once the PUSH is received so for that I could:
post a Notification with NSNotificaitonCenter
to resign all textfields/textviews (if anyone is firstResponder
). For this I have to keep active pointer to the currently active textfield/textview in all controllers.
make a variable in AppDelegate and assign the active textfields/textviews to it and on PUSH, and resignFirstResponder
of those on PUSH.
Both of the solutions would require making changes to all controller's code and I am looking for something more generic like:
these could be generic solutions.
It would be really helpful if someone could facilitate this thought process or someone have any immediate solution for this case.
You can use the method below
[[[UIApplication sharedApplication] keyWindow] endEditing:YES]
Try this one , for me it works fine
[yourView endEditing:YES]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With