Author Topic: How to position a single item in a grid to the top of the UIScrollView  (Read 2232 times)

stepanchik

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 9
    • View Profile
Hi, I have a UIScrollView with dynamically added items to UIGrid.
Every time I add few items, they are positioned in the middle of the Scroll View. I want to position them at the top of the Scroll View, but nothing helps.

I set UIScrollView Content origin to the TopLeft, Movement is Vertical, CancelDragIfFits is off, Restrict Within Panel is ON.
For UIGrid: Arrangement is Vertical, RowLimit is unlimited, Pivot is TopLeft.

On Reposition call the items are arranged in the middle of the ScrollView instead of its top.
I tried to call the ResetPosition and UpdateScrollbars functions for ScrollView. Still with the same result...

Did I miss something?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
The best thing to do is to not use UIGrid, and instead write your own script that would position your children according to how you want them to be, in the order you want them to be.

Alternative is to turn on sorting on the UIGrid and name your items accordingly, such as "001", "002", etc.

stepanchik

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 9
    • View Profile
Re: How to position a single item in a grid to the top of the UIScrollView
« Reply #2 on: August 28, 2014, 09:09:57 AM »
How does sorting can help with the problem?
May be You did not understand what I wrote. You can see in the attached image the grid with 2 items. I would like, that the items will be positioned at very top of a container, but they are positioned at its middle.

stepanchik

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 9
    • View Profile
Re: How to position a single item in a grid to the top of the UIScrollView
« Reply #3 on: August 28, 2014, 09:11:25 AM »
I forgot to attach the image

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: How to position a single item in a grid to the top of the UIScrollView
« Reply #4 on: August 28, 2014, 09:16:25 PM »
Set the content origin for the scroll view to be on top. After populating your grid and Reposition() it, call UIScrollView's ResetPosition().