scroll a uitextfield and a uitextview in a uiscrollview

Discussion in 'iOS Programming' started by franium, Dec 3, 2010.

  1. franium macrumors member

    Joined:
    Nov 18, 2010
    #1
    Hi,

    I have a scrollview which contains a text field and a text view. I would that both two scrolled together. How can I do? Now only the text view scroll.

    Precisely, I would that the title scrolls up while the user writes in the textview and, if the user decides to set it, he can scrolls down and refind the textfield.

    Thanks
    Fran
     
  2. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #2
  3. franium, Dec 3, 2010
    Last edited: Dec 3, 2010

    franium thread starter macrumors member

    Joined:
    Nov 18, 2010
    #3
    Not exactly... I already use the keyboard notifications to reduce the frame of the scrollview. My problem is this: I have a scrollview and inside this scrollview I have put an uitextfield (which should represent a title) and an uitextview... I would that when the user writes in the textview and the text begins scrolling, also the uitextfield scrolls up (as if it went behind the navigation bar) and if the user wants to set the title he can scroll down and refind the uitextfield. I don't know if I succeed in explaining.... sorry for my bad english
    Thanks
    Fran
     
  4. dejo, Dec 3, 2010
    Last edited: Dec 3, 2010

    dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #4
    Maybe some pictures / screenshots would help.

    P.S. Please make sure you are accurate in describing your UI elements. The above quote contains no mention of a UITextView but it seems you are referring to two different UI elements.
     
  5. franium thread starter macrumors member

    Joined:
    Nov 18, 2010
    #5
    You are right... sorry. It is:
    I would that when the user writes in the textview and the text begins scrolling, also the uitextfield scrolls up (as if it went behind the navigation bar) and if the user wants to set the title he can scroll down and refind the uitextfield.
     
  6. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #6
    Some pictures still would help. For example, is the UITextField above or below the UITextView?
     
  7. franium thread starter macrumors member

    Joined:
    Nov 18, 2010
    #7
    It's very simple... In a scrollview I have the UITextField above the UITextView
     
  8. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #8
    In that case, I'm confused by this statement:
    If the UITextField has been scrolled off the top of the screen, wouldn't you scroll up to get back to it?
     
  9. franium thread starter macrumors member

    Joined:
    Nov 18, 2010
    #9
    The UITextField has been scrolled off the top of the screen and if the user wants to see it again and set it, he has to do tap, holding it, and move the finger towards the bottom. I thought that in english one says "scroll down", but I'm not sure.
     
  10. cnstoll macrumors 6502

    Joined:
    Aug 29, 2010
    #10
    You would say the user is "swiping down", and the result is that they are "scrolling up".
     
  11. franium thread starter macrumors member

    Joined:
    Nov 18, 2010
    #11
    Exactly, thanks.
     
  12. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #12
    Okay, so now that we're clear on swiping down to scroll up, what exactly are you trying to achieve again? You want the UITextField to automatically scroll up off the screen when the UITextView starts scrolling down, is that it? Does that mean you are expecting the text within the UITextView to not scroll out of view within its own frame and the size of the UITextView to expand as lines are added? I still think some pictures would help; perhaps a before and after kinda thing.
     
  13. franium thread starter macrumors member

    Joined:
    Nov 18, 2010
    #13
    In a certain sense I would that the uitextfield and the uitextview were tied, so that when the user writes in the textview both the uitextfield and the uitextview scroll up.
     
  14. dejo, Dec 3, 2010
    Last edited: Dec 3, 2010

    dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #14
    I don't think you're understanding that there is scrolling within the UITextView itself. The frame for it stays stationary.

    EDIT:
    Screenshot that refers to what I'm talking about attached.
     

    Attached Files:

  15. franium, Dec 4, 2010
    Last edited: Dec 4, 2010

    franium thread starter macrumors member

    Joined:
    Nov 18, 2010
    #15
    Thanks... I think that by disabling the scrolling in the textview and setting properly the contentSize of the scrollview are the only things that I can try to have a solution as close as possible to the result I want achieve.
     

Share This Page