UIKeyboardWillHide not triggered

前端 未结 5 1300
深忆病人
深忆病人 2021-01-20 12:43

I read many post here about this topic, but I wasn\'t able to find an answer to my question, so, hope you won\'t be bored about another UIKeyboard post :-)

In my vi

5条回答
  •  [愿得一人]
    2021-01-20 13:02

    If you read the documents for UIWindow it says that the notification object for these notifications is nil. You are passing self.view.window in as the object to the addObserver:selector:name:object: method. Try passing nil instead:

    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(keyboardWillShow:)
                                                 name:UIKeyboardWillShowNotification
                                               object:nil;
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(keyboardWillHide:)
                                                 name:UIKeyboardWillHideNotification
                                               object:nil];
    

提交回复
热议问题