Skip to content
Browse files

Add new public method: hideKeyboard

I have found that when I was using DAKeyboardControl
I have wanted to programmatically hide the keyboard 
created by DAKeyboardControl.

This commit adds a public method to the category,
allowing you to send a message to the receiving UIView
to hide the keyboard.

I have also replaced the occurrences in the code 
that were hiding the keyboard to use the new public method.
  • Loading branch information...
1 parent 50be057 commit 2a008c895458931b32466601b52da7e85e29c6b8 @hswolff hswolff committed Oct 3, 2012
Showing with 11 additions and 6 deletions.
  1. +2 −0 DAKeyboardControl/DAKeyboardControl.h
  2. +9 −6 DAKeyboardControl/DAKeyboardControl.m
View
2 DAKeyboardControl/DAKeyboardControl.h
@@ -21,4 +21,6 @@ typedef void (^DAKeyboardDidMoveBlock)(CGRect keyboardFrameInView);
- (CGRect)keyboardFrameInView;
+- (void)hideKeyboard;
+
@end
View
15 DAKeyboardControl/DAKeyboardControl.m
@@ -154,6 +154,13 @@ - (void)removeKeyboardControl
self.keyboardPanRecognizer = nil;
}
+- (void)hideKeyboard
+{
+ self.keyboardActiveView.hidden = YES;
+ self.keyboardActiveView.userInteractionEnabled = NO;
+ [self.keyboardActiveInput resignFirstResponder];
+}
+
#pragma mark - Input Notifications
- (void)responderDidBecomeActive:(NSNotification *)notification
@@ -364,9 +371,7 @@ - (void)panGestureDidChange:(UIPanGestureRecognizer *)gesture
completion:^(BOOL finished){
if (!within44Pixels)
{
- self.keyboardActiveView.hidden = YES;
- self.keyboardActiveView.userInteractionEnabled = NO;
- [self.keyboardActiveInput resignFirstResponder];
+ [self hideKeyboard];
}
}];
}
@@ -392,9 +397,7 @@ - (void)panGestureDidChange:(UIPanGestureRecognizer *)gesture
completion:^(BOOL finished){
if (!within44Pixels)
{
- self.keyboardActiveView.hidden = YES;
- self.keyboardActiveView.userInteractionEnabled = NO;
- [self.keyboardActiveInput resignFirstResponder];
+ [self hideKeyboard];
}
}];
}

0 comments on commit 2a008c8

Please sign in to comment.
Something went wrong with that request. Please try again.