TPKeyboardAvoiding icon indicating copy to clipboard operation
TPKeyboardAvoiding copied to clipboard

On 3.5" iOS device, with a view having Navi controller and 4 textFields, the content size is large then scroll view's frame when keyboard hides.

Open billchanums opened this issue 12 years ago • 7 comments
trafficstars

The view has 4 text fields and not higher then the root UIView's size.

I added a line to fix the issue:

  • (void)keyboardWillHide:(NSNotification*)notification { _keyboardRect = CGRectZero; _keyboardVisible = NO;

    // Restore dimensions to prior size [UIView beginAnimations:nil context:NULL]; [UIView setAnimationCurve:[[[notification userInfo] objectForKey:UIKeyboardAnimationCurveUserInfoKey] intValue]]; [UIView setAnimationDuration:[[[notification userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey] floatValue]]; self.contentInset = _priorInset; self.contentOffset = _originalContentOffset;

    ///////////////////////////////////////////////////// ///bill's fix on 3.5" view with a navi bar and 5 txtFields self.contentSize = self.frame.size; /////////////////////////////////////////////////////

    [self setScrollIndicatorInsets:self.contentInset]; _priorInsetSaved = NO; [UIView commitAnimations]; }

billchanums avatar Mar 22 '13 12:03 billchanums

Please correct me if wrong, but in case the original scroll was bigger than the frame (for example you have 30 uitextfields) after the keyboard goes away you won't be able to scroll anymore.

On mar 22, 2013, at 9:48, billchanums [email protected] wrote:

The view has 4 text fields and not higher then the root UIView's size.

I added a line to fix the issue:

(void)keyboardWillHide:(NSNotification*)notification { _keyboardRect = CGRectZero; _keyboardVisible = NO;

// Restore dimensions to prior size [UIView beginAnimations:nil context:NULL]; [UIView setAnimationCurve:[[[notification userInfo] objectForKey:UIKeyboardAnimationCurveUserInfoKey] intValue]]; [UIView setAnimationDuration:[[[notification userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey] floatValue]]; self.contentInset = _priorInset; self.contentOffset = _originalContentOffset;

///////////////////////////////////////////////////// ///bill's fix on 3.5" view with a navi bar and 5 txtFields self.contentSize = self.frame.size; /////////////////////////////////////////////////////

[self setScrollIndicatorInsets:self.contentInset]; _priorInsetSaved = NO; [UIView commitAnimations]; }

— Reply to this email directly or view it on GitHub.

Julioacarrettoni avatar Mar 22 '13 13:03 Julioacarrettoni

I believe I find the reason.

before and after this line: self.contentSize = self.frame.size;

(lldb) po self.contentSize.height $0 = 460 no Objective-C description available po self.contentSize.height $1 = 416 [no Objective-C description available]

My storyboard is base on 4"screen, and no "Use Autolayout". 460px is the 4"screen is view size inside the navi controller. I enabled add Autosizing option and no help....

billchanums avatar Mar 22 '13 13:03 billchanums

Cheers Bill - would you mind submitting a pull request?

Sent from my iPad

On 22 Mar 2013, at 23:48, billchanums [email protected] wrote:

The view has 4 text fields and not higher then the root UIView's size.

I added a line to fix the issue:

(void)keyboardWillHide:(NSNotification*)notification { _keyboardRect = CGRectZero; _keyboardVisible = NO;

// Restore dimensions to prior size [UIView beginAnimations:nil context:NULL]; [UIView setAnimationCurve:[[[notification userInfo] objectForKey:UIKeyboardAnimationCurveUserInfoKey] intValue]]; [UIView setAnimationDuration:[[[notification userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey] floatValue]]; self.contentInset = _priorInset; self.contentOffset = _originalContentOffset;

///////////////////////////////////////////////////// ///bill's fix e 3.5" view with a navi bar and 5 txtFields self.contentSize = self.frame.size; /////////////////////////////////////////////////////

[self setScrollIndicatorInsets:self.contentInset]; _priorInsetSaved = NO; [UIView commitAnimations]; }

— Reply to this email directly or view it on GitHub.

michaeltyson avatar Mar 22 '13 22:03 michaeltyson

My fix just work for the case that all textFields can be shown in the frame's bounds. I think a new var called _originalContentSize is need....

billchanums avatar Mar 25 '13 10:03 billchanums

I'm having the same issue. Any new developments about this?

nielsmouthaan avatar Jun 05 '13 09:06 nielsmouthaan

Same here!

Thermometer91 avatar Jul 23 '13 12:07 Thermometer91

Same here! Fix?

ghost avatar Nov 14 '13 19:11 ghost