Skip to content

Commit

Permalink
Revert "Refactor KVO"
Browse files Browse the repository at this point in the history
This reverts commit 5647777.
  • Loading branch information
danielamitay committed Feb 6, 2013
1 parent dd62157 commit 5352d1f
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions DAKeyboardControl/DAKeyboardControl.m
Expand Up @@ -133,11 +133,6 @@ - (void)addKeyboardControl:(BOOL)panning actionHandler:(DAKeyboardDidMoveBlock)a
[self.keyboardPanRecognizer setDelegate:self];
[self addGestureRecognizer:self.keyboardPanRecognizer];
}

[self addObserver:self
forKeyPath:@"keyboardActiveView.frame"
options:0
context:NULL];
}

- (CGRect)keyboardFrameInView
Expand Down Expand Up @@ -193,7 +188,6 @@ - (void)removeKeyboardControl

// Unregister any gesture recognizer
[self removeGestureRecognizer:self.keyboardPanRecognizer];
[self removeObserver:self forKeyPath:@"keyboardActiveView.frame"];

// Release a few properties
self.keyboardDidMoveBlock = nil;
Expand Down Expand Up @@ -337,9 +331,9 @@ - (void)observeValueForKeyPath:(NSString *)keyPath
change:(NSDictionary *)change
context:(void *)context
{
if([keyPath isEqualToString:@"keyboardActiveView.frame"] && self.keyboardActiveView)
if([keyPath isEqualToString:@"frame"] && object == self.keyboardActiveView)
{
CGRect keyboardEndFrameWindow = self.keyboardActiveView.frame;
CGRect keyboardEndFrameWindow = [[object valueForKeyPath:keyPath] CGRectValue];
CGRect keyboardEndFrameView = [self convertRect:keyboardEndFrameWindow fromView:self.keyboardActiveView.window];
if (self.keyboardDidMoveBlock && !self.keyboardActiveView.hidden)
{
Expand Down Expand Up @@ -589,6 +583,15 @@ - (UIView *)keyboardActiveView
- (void)setKeyboardActiveView:(UIView *)keyboardActiveView
{
[self willChangeValueForKey:@"keyboardActiveView"];
[self.keyboardActiveView removeObserver:self
forKeyPath:@"frame"];
if (keyboardActiveView)
{
[keyboardActiveView addObserver:self
forKeyPath:@"frame"
options:0
context:NULL];
}
objc_setAssociatedObject(self,
&UIViewKeyboardActiveView,
keyboardActiveView,
Expand Down

1 comment on commit 5352d1f

@rappier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This crash still comes in my Class on doing same scenarios for pushing and coming back to push again Viewcontroller

Please sign in to comment.