Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[UI Fix] Setting up the initial frame of the textview only when the mana... #29

Merged
merged 2 commits into from
Mar 11, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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