who is issuing my UIKeyboardDidHideNotification?

后端 未结 2 1360
自闭症患者
自闭症患者 2021-01-25 12:37

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

When I do :

    [[NSNotificationCenter default         


        
相关标签:
2条回答
  • 2021-01-25 13:24

    Object for UIKeyboardDidHideNotification is always nil. Try to add observer in viewWillAppear and remove in viewDidDisapper methods.

    0 讨论(0)
  • 2021-01-25 13:39

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

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

    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.

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

    0 讨论(0)
提交回复
热议问题