Skip to content

Commit

Permalink
Merge pull request #29 from esttorhe/master
Browse files Browse the repository at this point in the history
[UI Fix] Setting up the initial frame of the textview only when the mana...
  • Loading branch information
hackiftekhar committed Mar 11, 2014
2 parents 7f7bc52 + 1d29b62 commit 2509a57
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions KeyboardTextFieldDemo/IQKeyBoardManager/IQKeyboardManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -603,10 +603,13 @@ -(void)textFieldViewDidEndEditing:(NSNotification*)notification
{
[_textFieldView.window removeGestureRecognizer:tapGesture];

[UIView animateWithDuration:animationDuration delay:0 options:(animationCurve|UIViewAnimationOptionBeginFromCurrentState) animations:^{
_textFieldView.frame = textFieldViewIntialFrame;
} completion:^(BOOL finished) {
}];
// We check if there's a valid frame before resetting the textview's frame
if(!CGRectEqualToRect(textFieldViewIntialFrame, CGRectZero)){
[UIView animateWithDuration:animationDuration delay:0 options:(animationCurve|UIViewAnimationOptionBeginFromCurrentState) animations:^{
_textFieldView.frame = textFieldViewIntialFrame;
} completion:^(BOOL finished) {
}];
}

//Setting object to nil
_textFieldView = nil;
Expand All @@ -617,7 +620,8 @@ -(void)textFieldViewDidBeginEditing:(NSNotification*)notification
{
// Getting object
_textFieldView = notification.object;
textFieldViewIntialFrame = _textFieldView.frame;
// If the manager is not enabled and it can't adjust the textview set the initial frame to CGRectZero
textFieldViewIntialFrame = _enable && _canAdjustTextView ? _textFieldView.frame : CGRectZero;

//If autoToolbar enable, then add toolbar on all the UITextField/UITextView's if required.
if (_enableAutoToolbar)
Expand Down

0 comments on commit 2509a57

Please sign in to comment.