谁发出我的UIKeyboardDidHideNotification? [英] who is issuing my UIKeyboardDidHideNotification?

查看:425
本文介绍了谁发出我的UIKeyboardDidHideNotification?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想注册 UIKeyboardDidHideNotification 只有我的UIViewController正在发行。

I want to register to UIKeyboardDidHideNotification that only my UIViewController is issuing.

当我这样做时:

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidHide:) name:UIKeyboardDidHideNotification object:self];

我没有接到任何电话 keyboardDidHide:当我这样做时:

I'm not getting any calls to keyboardDidHide: and when I do :

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidHide:) name:UIKeyboardDidHideNotification object:nil];

我正在接收来自所有其他视图控制器的呼叫以及我自己的呼叫。

I'm getting calls from all the other view controller as well as my own.

如何注册仅由特定视图控制器引发的 UIKeyboardDidHideNotification

How can I register to the UIKeyboardDidHideNotification raised only by a specific view controller ?

推荐答案

您无法注册来自特定控制器的UIKeyboardDidHideNotification。

You have no way to register for a UIKeyboardDidHideNotification coming from a specific controller.

如果使用UIKeyboardWillHideNotification,您可以检查控制器中的其中一个UITextView是否是第一个响应者。

If using UIKeyboardWillHideNotification, you could check if one of the UITextView inside your controller is the first responder.

使用UIKeyboardDidHideNotification我猜你需要为所有UITextView使用委托方法并保存最后编辑过的方法。我没有想到任何其他选择。

Using UIKeyboardDidHideNotification I guess you need to use delegate methods for all your UITextView and save the last one that was edited. I don't think of any other alternative.

否则,如果问题是仅在可见控制器上执行UIKeyboardDidHideNotification调用的方法,@ sviatoslav-yakymiv的解决方案效果很好。

Else, if the issue is to perform the method called by UIKeyboardDidHideNotification only on the visible controller, the solution by @sviatoslav-yakymiv works well.

这篇关于谁发出我的UIKeyboardDidHideNotification?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆