Author Topic: UIScrollView free space in panel  (Read 1931 times)

MRKane

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 5
    • View Profile
UIScrollView free space in panel
« on: June 20, 2014, 09:44:26 PM »
Gidday,

Figured it was best to ask before going ahead and butchering code ;) I've searched through the forums and online, and there doesn't appear to be a topic addressing how the space in a scroll view is "handled" if you will.

I'm making a vertical UIScrollView as part of a project that has dynamic entries which can change size as the user expands or closes them. Thing is when the entries are all closed the panel isn't "full", leaving space either at the top or the bottom. Is there a built in function for making sure that any free space is at the bottom thus keeping my list at the top of the panel? I don't mind if the user dodges it around, as long as it returns to the top when its not being clipped.

Thanks so much!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIScrollView free space in panel
« Reply #1 on: June 21, 2014, 03:36:17 PM »
The UIScrollView has a Content Origin point you can set. Choose it to top, then after populating your content call UIScrollView's ResetPosition() function.

MRKane

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 5
    • View Profile
Re: UIScrollView free space in panel
« Reply #2 on: June 21, 2014, 08:18:09 PM »
Thank you so much for the fast reply!

I'm afraid that doesn't work and it seems that the list can still be positioned within the scroll box so that there's free space at the top of a short list instead of the bottom. I'll hobble together short script similar to UICenterOnChild to handle it - what I'm doing with the scrollbox is pretty dynamic and that might be what's breaking it. Do tell me if anything else springs to mind :)

Cheers anyway!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIScrollView free space in panel
« Reply #3 on: June 22, 2014, 10:47:32 PM »
There will be some padding due to the soft border, unless you change the clipped border to be 0. If that's not it, a pic showing the issue would help.

MRKane

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 5
    • View Profile
Re: UIScrollView free space in panel
« Reply #4 on: June 24, 2014, 11:48:38 PM »
Sorry about the delay in replying but the hassles of work got int the way.

I've attached a screenshot of the problem - essentially a list is smaller than the panel and I couldn't get it to spring back up to the top (for neatness mainly). I've since modified function to resolve the issue - just couldn't find a thread resolving the issue so this might be helpful for someone else at some stage.

Again thank you - NGUI is a cracker product in more ways than just one!