Skip to content

Commit

Permalink
Merge pull request #169 from AnthonyMDev/AnthonyMDev-Master
Browse files Browse the repository at this point in the history
Skip disabled text fields when using 'focusNextTextField'
  • Loading branch information
michaeltyson committed Jun 17, 2015
2 parents 87eaf03 + da34bb3 commit b154752
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions TPKeyboardAvoiding/UIScrollView+TPKeyboardAvoidingAdditions.m
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,7 @@ - (void)TPKeyboardAvoiding_findTextFieldAfterTextField:(UIView*)priorTextField b
// Search recursively for text field or text view below priorTextField
CGFloat priorFieldOffset = CGRectGetMinY([self convertRect:priorTextField.frame fromView:priorTextField.superview]);
for ( UIView *childView in view.subviews ) {
if ( childView.hidden ) continue;
if ( ([childView isKindOfClass:[UITextField class]] || [childView isKindOfClass:[UITextView class]]) && childView.isUserInteractionEnabled) {
if ([self TPKeyboardAvoiding_viewIsNextTextField:childView]) {
CGRect frame = [self convertRect:childView.frame fromView:view];
if ( childView != priorTextField
&& CGRectGetMinY(frame) >= priorFieldOffset
Expand All @@ -215,6 +214,24 @@ - (void)TPKeyboardAvoiding_findTextFieldAfterTextField:(UIView*)priorTextField b
}
}

- (BOOL)TPKeyboardAvoiding_viewIsNextTextField:(UIView *)view {
if (view.hidden) return NO;

if ([view isKindOfClass:[UITextField class]]) {
UITextField *textField = (UITextField *)view;
if (!textField.enabled) return NO;

}

if ( ([view isKindOfClass:[UITextField class]] ||
[view isKindOfClass:[UITextView class]])
&& view.isUserInteractionEnabled) {
return YES;
}

return NO;
}

- (void)TPKeyboardAvoiding_assignTextDelegateForViewsBeneathView:(UIView*)view {
for ( UIView *childView in view.subviews ) {
if ( ([childView isKindOfClass:[UITextField class]] || [childView isKindOfClass:[UITextView class]]) ) {
Expand Down

0 comments on commit b154752

Please sign in to comment.