Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Vertical Layout Table View - Layout goes wrong when scrolling

I've got a lot of info coming in via an xhr request that I'm trying to stick into a table view. The info can be of varying length so the vertical layout and auto height seemed a logical solution.

Everything works ok on first load but scrolling up and down (simulator and device) causes the layout to go out of sync, the text ends up outside it's containing row.

I've created a gist of a simplified test case, the issue seems to occur when the rows contain varying amounts of text i.e. the need to be different heights, the example in KitchenSink all the rows are of the same autoheight and the bug does not occur. Not sure if I'm doing something daft or if this is just a bug in Titanium or indeed the native rendering?

Testing on iphone simulator and device running 3.1.3

— asked March 11th 2010 by Alan Wallace
  • bug
  • iphone
  • table view
  • vertical layout
0 Comments

5 Answers

  • Accepted Answer

    I would recommend setting the height of each row depending on the length of the text in each row and how many line returns each has. So take a length of each label instead of using auto. That worked for me, it does the same thing and gives more control.

    I would also set the width of each label and trim if its over a certain length, adding a …

    — answered March 11th 2010 by John Welch
    permalink
    0 Comments
  • Hmmm the link to the gist didn't get posted, it's here:

    [gist on github] (http://gist.github.com/329629)

    — answered March 11th 2010 by Alan Wallace
    permalink
    0 Comments
  • Thanks John, I'll give that a try. I might file a bug for the auto height though, I'm sure this is not the expected behaviour.

    — answered March 12th 2010 by Alan Wallace
    permalink
    0 Comments
  • Thanks John, I'll give that a try. I might file a bug for the auto height though, I'm sure this is not the expected behaviour.

    — answered March 12th 2010 by Alan Wallace
    permalink
    0 Comments
  • Just posting a follow up - I think I may have fixed this issue by explicitly setting top, bottom, left and right values for each label within the view. This seems to allow the phone to calculate the positions much better.

    — answered March 14th 2010 by Alan Wallace
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.