TPKeyboardAvoiding icon indicating copy to clipboard operation
TPKeyboardAvoiding copied to clipboard

Active scroll before to active a textfield

Open llKoull opened this issue 10 years ago • 9 comments

Hi!

I've made a form with many fields using TPKeyboardAvoidingScrollView and when I touch any of the Textfields, the scrollview works fantastic. But the problem is that I need to use the Scroll View before to activate a Textfield and I can't do this 😟

I also tried to do something like [nameTextField becomeFirstResponder]; in viewdidload, viewdidapper and viewwillappear but nothing happens. The keyboards comes up but the scroll view doesn't work, It only works if I touch the field.

Thanks!

llKoull avatar Apr 08 '14 14:04 llKoull

same here :+1:

iferrera avatar Apr 08 '14 15:04 iferrera

+1

mmackowiak avatar Apr 16 '14 23:04 mmackowiak

this works for me but seems to randomly cause a crash on the if here when i call becomeFirstResponder on one of my two textviews

- (UIView*)TPKeyboardAvoiding_findFirstResponderBeneathView:(UIView*)view {
    // Search recursively for first responder
    for ( UIView *childView in view.subviews ) {
        if ( [childView respondsToSelector:@selector(isFirstResponder)] && [childView isFirstResponder] ) return childView;
        UIView *result = [self TPKeyboardAvoiding_findFirstResponderBeneathView:childView];
        if ( result ) return result;
    }
    return nil;
}

mrtristan avatar Apr 18 '14 18:04 mrtristan

@llKoull Did you find a working solution for this? I am also facing the same issue, the scrollview is initially not moving and starts to move only after I touch any of the textfields

Any help appreciated.

icodebuster avatar Apr 29 '14 17:04 icodebuster

Nope, sry Jobi but i didn’t find any solutions yet 😟 I just changed the design of my view to fit all the things on It.

Regards,

RAÚL VIDAL MUIÑOS, CEO/Founder Devinet T: (+34) 931 801 823 M: (+34) 675 575 782 F: (+34) 932 843 075

El 29/04/2014, a las 19:46, Jobin Kurian [email protected] escribió:

@llKoull Did you find a working solution for this? I am also facing the same issue, the scrollview is initially not moving and starts to move only after I touch any of the textfields

Any help appreciated.

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

llKoull avatar Apr 29 '14 17:04 llKoull

@llKoull The working solution I could do was to give IBOutlet to the scrollvew and set its content size

[_scrollView setContentSize:CGSizeMake(320, 500)];

This made the scrollview scrollable and was working as required.

icodebuster avatar Apr 30 '14 08:04 icodebuster

Hey @icodebuster , I'm having the same issue as well, and I also tried your solution, but sadly it doesn't work for me. Did you (or anyone here) manage to find a better solution by any chance?

orenk86 avatar Jul 07 '14 16:07 orenk86

@orenk86 If you are using storyboard with AutoLayout and UIScrollview, you no longer set the contentSize explicitly. The AutoLayout System calculates the contentSize based on your constraints. So give correct constraints to your text fields and it should work. I had the issue fixed with correct constraints to the UI Components on my scrollview.

Hope this helps.

icodebuster avatar Jul 07 '14 16:07 icodebuster

@icodebuster Turns out that was exactly the problem. It works like a charm now! Thanks a million!! :)

orenk86 avatar Jul 10 '14 07:07 orenk86