Author Topic: UIScrollView and UIScrollBar woes  (Read 2797 times)

drawmaster77

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 21
    • View Profile
UIScrollView and UIScrollBar woes
« on: July 08, 2014, 11:27:24 PM »
I am dynamically resizing items in UIGrid and having problems with these two components. UIScrollbar is not repositioning to accomodate for newly added/deleted elements, the only way I can get it to work is if I change standalone resolution and then change it back original.

edit: I am calling scrlView.UpdateScrollbars(true); after I've repopulated the UIGrid
edit: the problem is the timing issue, items are added after the scroll view is updated. I don't know what is a clean way to resolve this issue... because I have a function that populates UIGrid by creating new items from prefabs and instantly after that calls scrrollView.UpdatePosition but I am guessing the panel doesn't acknowledge new bounds until next frame or something. It's somewhat frustrating that there is no built-in functionality to notify the scrollview that it needs to update (is there?), perhaps something like boundsChanged flag/event would be useful here. Or scrollView directly could keep track whether bounds of its contents were changed every frame.
« Last Edit: July 09, 2014, 04:37:27 AM by drawmaster77 »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIScrollView and UIScrollBar woes
« Reply #1 on: July 09, 2014, 04:53:08 PM »
Call UIScrollView.UpdateScrollbars(true);

The 'true' indicates you want bounds to be re-calculated. Update position shouldn't be needed but you can call it after if you want. What's the full code you're using here?

P.S. There is also UIScrollView.InvalidateBounds.