Make UIScrollView scroll to the bottom?

Discussion in 'iOS Programming' started by jsnuff1, Sep 21, 2008.

  1. jsnuff1 macrumors 6502a

    Joined:
    Oct 4, 2003
    Location:
    NY
    #1
    I have a scroll view that adds content to the bottom of the view when a user does something. Unfortunately the view does not automatically scroll to the bottom when there is a new content update, and the user has to manualy scroll to the bottom to see the new content.

    Is there a way to make UIScrollView automatically scroll to the bottom of the view when there is an update to the view?

    Thanks.
     
  2. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #2
    Are you adding content to the view or just changing the contents of a view that's already added to the scrollview?

    Did you try this:

    Code:
    - (void)scrollRectToVisible:(CGRect)rect animated:(BOOL)animated;         // scroll so rect is just visible (nearest edges). nothing if rect completely visible
     
  3. jsnuff1 thread starter macrumors 6502a

    Joined:
    Oct 4, 2003
    Location:
    NY
    #3
    im adding content, but i figured it out anyway.

    [updateTextView scrollRangeToVisible:NSMakeRange([updateTextView.text length], 0)];

    calling that method will do the trick for a UITextView. I think the method that phoneydevloper posted is for a UIScrollView.
     
  4. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #4
    Um yeah, that method is in UIScrollView, because that's what you asked about.
     

Share This Page