Papercloud / KeyboardConstraint

A NSLayoutConstraint subclass which observes keyboard notifications.
MIT License
14 stars 2 forks source link

Enable/Disable keyboard notifications. #4

Open markst opened 9 years ago

markst commented 9 years ago

When pushing a new view controller to a nav stack, it's common to have behaviour such as:

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self.firstNameTextFieldView becomeFirstResponder];
}

- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];

    [self.firstNameTextFieldView resignFirstResponder];
    [self.lastNameTextFieldView  resignFirstResponder];
}

Which allows the keyboard to remain visible when pushing a new vc which will take on the first responder before it appears.

However, UIKeyboardWillHideNotification notifications are sent when text field's stop becoming first responder & regardless of whether the keyboard is showing or hiding.