Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Handle keyboard being active during setup. Closes #56

  • Loading branch information...
commit 4d8300f3e447b5c3390e059a5d9f634de52adcb5 1 parent 4218b13
@danielamitay authored
Showing with 19 additions and 7 deletions.
  1. +19 −7 DAKeyboardControl/DAKeyboardControl.m
View
26 DAKeyboardControl/DAKeyboardControl.m
@@ -54,6 +54,15 @@ - (void)addKeyboardControl:(BOOL)panning actionHandler:(DAKeyboardDidMoveBlock)a
self.panning = panning;
self.keyboardDidMoveBlock = actionHandler;
+ // Check to see if the keyboard is already active, and setup accordingly
+ self.keyboardActiveInput = [self findFirstResponder];
+ if (self.keyboardActiveInput) {
+ self.keyboardActiveView = self.keyboardActiveInput.inputAccessoryView.superview;
+ if (self.keyboardActiveView && self.panning && !self.keyboardPanRecognizer) {
+ [self setupGestureRecognizer];
+ }
+ }
+
// Register for text input notifications
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(responderDidBecomeActive:)
@@ -202,13 +211,7 @@ - (void)inputKeyboardWillShow:(NSNotification *)notification
}
completion:^(__unused BOOL finished){
if (self.panning && !self.keyboardPanRecognizer) {
- // Register for gesture recognizer calls
- self.keyboardPanRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self
- action:@selector(panGestureDidChange:)];
- [self.keyboardPanRecognizer setMinimumNumberOfTouches:1];
- [self.keyboardPanRecognizer setDelegate:self];
- [self.keyboardPanRecognizer setCancelsTouchesInView:NO];
- [self addGestureRecognizer:self.keyboardPanRecognizer];
+ [self setupGestureRecognizer];
}
}];
}
@@ -442,6 +445,15 @@ - (UIView *)findFirstResponder
return nil;
}
+- (void)setupGestureRecognizer
+{
+ self.keyboardPanRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panGestureDidChange:)];
+ self.keyboardPanRecognizer.minimumNumberOfTouches = 1;
+ self.keyboardPanRecognizer.delegate = self;
+ self.keyboardPanRecognizer.cancelsTouchesInView = NO;
+ [self addGestureRecognizer:self.keyboardPanRecognizer];
+}
+
#pragma mark - UIView Method Overrides
Please sign in to comment.
Something went wrong with that request. Please try again.