Author Topic: Repositioning UITable to bottom item  (Read 1624 times)

hrlarsen

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 3
  • Posts: 35
    • View Profile
Repositioning UITable to bottom item
« on: June 26, 2014, 11:19:53 AM »
Hi there,

I'm currently building a chat system, and I want it to be so that when a chat message is received/sent it will appear in the chat, in the bottom of a list. Since each chat message might vary in length, and thereby determine the size of the widget, UIGrid is not an option since, to my knowledge, it is restricted the equal sized objects. Therefore I am using a UITable to do the job. My problem is that every time a new object is added to the list, I would like some way to scroll down the list. The table is placed under a UIScrollView, so I've been playing around adding momentum to the scrollview, but it seems to be a bad solution because it then jumps more than I want it to.

I would imagine someone have come across this issue before, and would appreciate any help or suggestions.

Best regards

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Repositioning UITable to bottom item
« Reply #1 on: June 26, 2014, 11:30:53 AM »
NGUI comes with a chat window example. Did you have a look at it? If you have the Starlink UI Starter Kit package, there is also another chat window there that's done differently.

hrlarsen

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 3
  • Posts: 35
    • View Profile
Re: Repositioning UITable to bottom item
« Reply #2 on: June 27, 2014, 03:57:33 AM »
I had a look at the example, and this is fine when you are making a simple chat, but my chat appears in "bubbles" so this is why the chat example would not work as expected. I did however yesterday find a solution with momentum, but then I had to restrict the scrollview to have only momentum (not including spring). So everytime a new message is received or entered a high momentum force is applied which makes the list scroll to the bottom.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Repositioning UITable to bottom item
« Reply #3 on: June 27, 2014, 01:20:33 PM »
You can also achieve this kind of an effect by using anchors instead of a table. Since you want them to appear on the bottom, each entry would be anchored to the newer one in line, in a chain.